Improve Client CLI help readability (#2073)

Currently the CLI `-h/--help` commad output is almost unreadable as (for
some commands) it:
- doesn't provide a short brief of what the command does.
- doesn't separate the options description in smaller paragraphs.
- doesn't use a smart wrap strategy for lines longer than the number of
columns in the terminal.

Follow some pics taken with a 100 cols wide term

## Short help (./node -h)

### Before


![20231028-174531-grim](https://github.com/paritytech/polkadot-sdk/assets/8143589/11b62c3c-dcd5-43f4-ac58-f1b299e3f4b9)

### After


![20231028-175041-grim](https://github.com/paritytech/polkadot-sdk/assets/8143589/dc08f6fd-b287-40fb-8b33-71a185922104)


## Long help (./node --help)

### Before


![20231028-175257-grim](https://github.com/paritytech/polkadot-sdk/assets/8143589/9ebdc0ae-54ee-4760-b873-a7e813523cb6)

### After


![20231028-175155-grim](https://github.com/paritytech/polkadot-sdk/assets/8143589/69cbe5cb-eb2f-46a5-8ebf-76c0cf8c4bad)

---------

Co-authored-by: command-bot <>
This commit is contained in:
Davide Galassi
2023-10-29 18:25:33 +01:00
committed by GitHub
parent 8ce16ee6ff
commit 7035034710
16 changed files with 190 additions and 97 deletions
@@ -32,39 +32,49 @@ const NODE_KEY_ED25519_FILE: &str = "secret_ed25519";
/// used for libp2p networking.
#[derive(Debug, Clone, Args)]
pub struct NodeKeyParams {
/// The secret key to use for libp2p networking.
/// Secret key to use for p2p networking.
///
/// The value is a string that is parsed according to the choice of
/// `--node-key-type` as follows:
/// `ed25519`:
/// The value is parsed as a hex-encoded Ed25519 32 byte secret key,
/// i.e. 64 hex characters.
///
/// - `ed25519`: the value is parsed as a hex-encoded Ed25519 32 byte secret key (64 hex
/// chars)
///
/// The value of this option takes precedence over `--node-key-file`.
///
/// WARNING: Secrets provided as command-line arguments are easily exposed.
/// Use of this option should be limited to development and testing. To use
/// an externally managed secret key, use `--node-key-file` instead.
#[arg(long, value_name = "KEY")]
pub node_key: Option<String>,
/// The type of secret key to use for libp2p networking.
/// Crypto primitive to use for p2p networking.
///
/// The secret key of the node is obtained as follows:
/// * If the `--node-key` option is given, the value is parsed as a secret key according to
/// the type. See the documentation for `--node-key`.
/// * If the `--node-key-file` option is given, the secret key is read from the specified
/// file. See the documentation for `--node-key-file`.
/// * Otherwise, the secret key is read from a file with a predetermined, type-specific name
/// from the chain-specific network config directory inside the base directory specified by
/// `--base-dir`. If this file does not exist, it is created with a newly generated secret
/// key of the chosen type.
///
/// - If the `--node-key` option is given, the value is parsed as a secret key according to the
/// type. See the documentation for `--node-key`.
///
/// - If the `--node-key-file` option is given, the secret key is read from the specified file.
/// See the documentation for `--node-key-file`.
///
/// - Otherwise, the secret key is read from a file with a predetermined, type-specific name
/// from the chain-specific network config directory inside the base directory specified by
/// `--base-dir`. If this file does not exist, it is created with a newly generated secret
/// key of the chosen type.
///
/// The node's secret key determines the corresponding public key and hence the
/// node's peer ID in the context of libp2p.
#[arg(long, value_name = "TYPE", value_enum, ignore_case = true, default_value_t = NodeKeyType::Ed25519)]
pub node_key_type: NodeKeyType,
/// The file from which to read the node's secret key to use for libp2p networking.
/// File from which to read the node's secret key to use for p2p networking.
///
/// The contents of the file are parsed according to the choice of `--node-key-type`
/// as follows:
/// `ed25519`:
/// The file must contain an unencoded 32 byte or hex encoded Ed25519 secret key.
///
/// - `ed25519`: the file must contain an unencoded 32 byte or hex encoded Ed25519 secret key.
///
/// If the file does not exist, it is created with a newly generated secret key of
/// the chosen type.
#[arg(long, value_name = "FILE")]