Skip to content

Commit

Permalink
neard: improve localnet command arguments (near#6808)
Browse files Browse the repository at this point in the history
Expectation for single-letter options is that they are passed as short
switches with a single dash.  However, currently LocalnetCmd breaks
that expectation by using ‘n’ and ‘v’ as long option names.  This
means that ‘neard localnet -v 3’ won’t work and instead an unorthodox
‘neard localnet --v 3’ needs to be used.

To bring the command parsing closer with established practices, add
proper long names for validators and non_validators options, introduce
short names for them and, to keep backwards compatibility, retain the
old long names as aliases (the aliases won’t show up in help message).

While at it, add ‘-s’ short name to ‘--shards’ and add documentation
for currently undocumented ‘--archival-node’ and ‘--fixed-shards’.
  • Loading branch information
mina86 authored May 24, 2022
1 parent 79c6b4b commit 9588183
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions neard/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,21 +522,23 @@ async fn wait_for_interrupt_signal(home_dir: &Path, mut rx_crash: Receiver<()>)
#[derive(Parser)]
pub(super) struct LocalnetCmd {
/// Number of non-validators to initialize the localnet with.
#[clap(long = "n", default_value = "0")]
#[clap(short = 'n', long, alias = "n", default_value = "0")]
non_validators: NumSeats,
/// Prefix the directory name for each node with (node results in node0, node1, ...)
/// Prefix for the directory name for each node with (e.g. ‘node’ results in
/// ‘node0’, ‘node1’, ...)
#[clap(long, default_value = "node")]
prefix: String,
/// Number of shards to initialize the localnet with.
#[clap(long, default_value = "1")]
#[clap(short = 's', long, default_value = "1")]
shards: NumShards,
/// Number of validators to initialize the localnet with.
#[clap(long = "v", default_value = "4")]
#[clap(short = 'v', long, alias = "v", default_value = "4")]
validators: NumSeats,
// Whether to create fixed shards accounts (that are tied to a given shard).
/// Whether to create fixed shards accounts (that are tied to a given
/// shard).
#[clap(long)]
fixed_shards: bool,
// Archival nodes
/// Whether to configure nodes as archival.
#[clap(long)]
archival_nodes: bool,
}
Expand Down

0 comments on commit 9588183

Please sign in to comment.