-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3493 from iron-fish/staging
STAGING -> MASTER (02/21/23)
- Loading branch information
Showing
155 changed files
with
5,447 additions
and
2,805 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# CLI UX Guide | ||
|
||
The Iron Fish CLI is for humans before machines. The primary goal of anyone developing CLI plugins should always be usability. Input and output should be consistent across commands to allow the user to easily learn how to interact with new commands. | ||
|
||
Based on https://devcenter.heroku.com/articles/cli-style-guide | ||
|
||
## Naming the command | ||
The CLI is made up of topics and commands. For the command `ironfish migrations:start`, migrations is the topic and start is the command. | ||
|
||
Generally topics are plural nouns and commands are verbs. | ||
|
||
Topic and command names should always be a single, lowercase word without spaces, hyphens, underscores, or other word delimiters. Colons, however, are allowed as this is how to define subcommands (such as `ironfish wallet:transactions:add`). If there is no obvious way to avoid having multiple words, separate with kebab-case: `ironfish service:estimate-fee-rates` | ||
|
||
Because topics are generally nouns, the root command of a topic usually lists those nouns. So in the case of `ironfish migrations`, it will list all the migrations. Never create a *:list command such as `ironfish migrations:list`. | ||
|
||
## Command Description | ||
Topic and command descriptions should be provided for all topics and commands. They should fit on 80 character width screens, begin with a lowercase character, and should not end in a period. | ||
|
||
## Input | ||
Input to commands is typically provided by flags and args. Stdin can also be used in cases where it is useful to stream files or information in (such as with heroku run). | ||
|
||
### Flags | ||
|
||
Flags are preferred to args when there are many inputs, particularly inputs of the same type. They involve a bit more typing, but make the use of the CLI clearer. For example, `ironfish wallet:send` used to accept an argument for the account to use, as well as --to flag to specify the account to send to. | ||
|
||
So using `ironfish wallet:send` used to work like this: | ||
|
||
```bash | ||
$ ironfish wallet:send source_account --to dest_account | ||
``` | ||
|
||
This is confusing to the user since it isn’t clear which account they are sending from and which one they are sending to. By switching to required flags, we instead expect input in this form: | ||
|
||
```bash | ||
ironfish wallet:send --from source_account --to dest_account | ||
``` | ||
|
||
This also allows the user to specify the flags in any order, and gives them the confidence that they are running the command correctly. It also allows us to show better error messages. | ||
|
||
Ensure that descriptions are provided for all flags, that the descriptions are in lowercase, that they are concise (so as to fit on narrow screens), and that they do not end in a period to match other flag descriptions. | ||
|
||
|
||
### Arguments | ||
Arguments are the basic way to provide input for a command. While flags are generally preferred, they are sometimes unnecessary in cases where there is only 1 argument, or the arguments are obvious and in an obvious order. | ||
|
||
In the case of `ironfish chain:power`, we can specify the block sequence we want to determine the network mining power with an argument. We can also specify how many blocks back to look to average the mining power with a flag. | ||
|
||
```bash | ||
ironfish chain:power 5432 --history 20 | ||
``` | ||
|
||
If this was done with only arguments, it wouldn’t be clear if the sequence should go before or after the number of blocks to use to sample the network mining power. Using a required flag instead allows the user to specify it either way. | ||
|
||
### Prompting | ||
Prompting for missing input provides a nice way to show complicated options in the CLI. For example, `ironfish wallet:use` shows the following if no account is specified as an arg. | ||
|
||
``` | ||
$ ironfish wallet:use | ||
? Which wallet would you like to use? (Use arrow keys) | ||
❯ vitalik | ||
satoshi | ||
jason | ||
``` | ||
|
||
> ℹ️ Use [inquirer](https://github.com/sboudrias/Inquirer.js) to show prompts like this. | ||
However, if prompting is required to complete a command, this means the user will not be able to script the command. Ensure that args or flags can always be provided to bypass the prompt. In this case, `ironfish wallet:use` can take in an argument for the account to set as default to skip the prompt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ironfish", | ||
"version": "0.1.67", | ||
"version": "0.1.68", | ||
"description": "CLI for running and interacting with an Iron Fish node", | ||
"author": "Iron Fish <[email protected]> (https://ironfish.network)", | ||
"main": "build/src/index.js", | ||
|
@@ -59,8 +59,8 @@ | |
"@aws-sdk/s3-request-presigner": "3.127.0", | ||
"@aws-sdk/client-cognito-identity": "3.215.0", | ||
"@aws-sdk/client-s3": "3.127.0", | ||
"@ironfish/rust-nodejs": "0.1.26", | ||
"@ironfish/sdk": "0.0.44", | ||
"@ironfish/rust-nodejs": "0.1.27", | ||
"@ironfish/sdk": "0.0.45", | ||
"@oclif/core": "1.23.1", | ||
"@oclif/plugin-help": "5.1.12", | ||
"@oclif/plugin-not-found": "2.3.1", | ||
|
@@ -70,6 +70,7 @@ | |
"blessed": "0.1.81", | ||
"blru": "0.1.6", | ||
"buffer-map": "0.0.7", | ||
"chalk": "4.1.2", | ||
"inquirer": "8.2.5", | ||
"json-colorizer": "2.2.2", | ||
"segfault-handler": "1.3.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
import { Flags } from '@oclif/core' | ||
import { IronfishCommand } from '../../command' | ||
import { RemoteFlags } from '../../flags' | ||
|
||
export class UnsetCommand extends IronfishCommand { | ||
static description = `Unset a value in the config and fall back to default` | ||
|
||
static args = [ | ||
{ | ||
name: 'name', | ||
parse: (input: string): Promise<string> => Promise.resolve(input.trim()), | ||
required: true, | ||
description: 'Name of the config item', | ||
}, | ||
] | ||
|
||
static flags = { | ||
...RemoteFlags, | ||
local: Flags.boolean({ | ||
default: false, | ||
description: 'Dont connect to the node when updating the config', | ||
}), | ||
} | ||
|
||
static examples = ['$ ironfish config:unset blockGraffiti'] | ||
|
||
async start(): Promise<void> { | ||
const { args, flags } = await this.parse(UnsetCommand) | ||
const name = args.name as string | ||
|
||
const client = await this.sdk.connectRpc(flags.local) | ||
await client.unsetConfig({ name }) | ||
|
||
this.exit(0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.