Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create command line examples for --help #5374

Closed
JoshuaBatty opened this issue Dec 7, 2023 · 1 comment
Closed

Create command line examples for --help #5374

JoshuaBatty opened this issue Dec 7, 2023 · 1 comment
Assignees
Labels

Comments

@JoshuaBatty
Copy link
Member

We should add some common examples of commands that users might want to run when they type --help on a forc binary. The idea is to act like a "clippy" and minimise the need for users to leave the command line to reach for the docs to proceed with common operations of our tools.

Let's start by adding between 1-3 examples for the following programs.

  • forc tx
  • forc doc
  • forc index
  • forc deploy
  • forc crypto
  • forc run

Note, some of these like forc doc might only need one or two examples, where forc tx could benefit for more examples depending on what --help was called on.

Currently only forc wallet has examples. Here is what they look like for reference.

EXAMPLES:
    # Create a new wallet at the default path `~/.fuel/wallets/.wallet`.
    forc wallet new

    # Import a new wallet from a mnemonic phrase.
    forc wallet import

    # Derive a new account for the default wallet.
    forc wallet account new

    # Derive a new account for the wallet at the given path.
    forc wallet --path /path/to/wallet account new

    # Derive (or re-derive) the account at index 5.
    forc wallet account 5 new

    # Sign a transaction ID with account at index 3.
    forc wallet account 3 sign tx-id 0x0bf34feb362608c4171c87115d4a6f63d1cdf4c49b963b464762329488f3ed4f

    # Sign an arbitrary string.
    forc wallet account 3 sign string "blah blah blah"

    # Sign the contents of a file.
    forc wallet account 3 sign file /path/to/data-to-sign

    # Sign a hex-encoded byte string.
    forc wallet account 3 sign hex "0xDEADBEEF"

    # You can also use the `sign` subcommand directly. The following gives the same result.
    forc wallet sign --account 3 string "blah blah blah"

    # Sign directly with a private key.
    forc wallet sign --private-key string "blah blah blah"

    # Temporarily display the private key of the account at index 0.
    forc wallet account 0 private-key

    # Show the public key of the account at index 0.
    forc wallet account 0 public-key

    # Transfer 1 token of the base asset id to a bech32 address at the gas price of 1.
    forc wallet account 0 transfer --to fuel1dq2vgftet24u4nkpzmtfus9k689ap5avkm8kdjna8j3d6765yfdsjt6586
    --amount 1 --asset-id 0x0000000000000000000000000000000000000000000000000000000000000000 --gas-price 1

    # Transfer 1 token of the base asset id to a hex address at the gas price of 1.
    forc wallet account 0 transfer --to 0x0b8d0f6a7f271919708530d11bdd9398205137e012424b611e9d97118c180bea
    --amount 1 --asset-id 0x0000000000000000000000000000000000000000000000000000000000000000 --gas-price 1
@crodas crodas mentioned this issue Dec 22, 2023
7 tasks
crodas added a commit that referenced this issue Jan 10, 2024
## Description

Fixes #5398, #5374

Add examples to our `--help` cli. The examples are defined through the a
macro `forc::cli_examples { }` and each of these examples is part of the
the test suite of the crate. This is done to ensure the documentation is
always up to date or updated whenever the tests are not passing.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Braqzen <[email protected]>
@crodas
Copy link
Contributor

crodas commented Jan 17, 2024

Fixed in #5388 and will continue in #5444 (and FuelLabs/forc-wallet#157)

@crodas crodas closed this as completed Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants