Skip to content

Commit e58d2af

Browse files
committed
docs: improve --help output for agent usability
Addresses all items from #491, plus one additional gap found during a full help audit: - canister settings update: fill in empty descriptions for --compute-allocation, --log-visibility, --add/remove/set-log-viewer, --add/remove-environment-variable; clarify that --log-visibility only accepts 'controllers'/'public', not 'allowed-viewers' - canister settings show: fix description from "status" to "settings"; fix "enviroment" typo; note no default-to-all behaviour - canister status: document that omitting [CANISTER] queries all canisters in the environment; fix "enviroment" typo; add examples - network start: document default port 8000, gateway.port config, and --project-root-override tip for port conflicts - new: replace misleading template_values_file reference in --silent with accurate non-interactive/CI guidance; improve --define description to mention template-specific variable names and relationship to --silent - canister list: document plain-text and JSON output formats - environment list: fix "enviroments" typo; add context about icp project show - cycles transfer: fix //// comment to /// so --from-subaccount gets a description - cycles mint: document that exactly one of --icp or --cycles is required - docs/reference/cli.md: regenerated
1 parent caeac37 commit e58d2af

File tree

10 files changed

+102
-33
lines changed

10 files changed

+102
-33
lines changed

crates/icp-cli/src/commands/canister/list.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use serde::Serialize;
66

77
use crate::options::EnvironmentOpt;
88

9-
/// List the canisters in an environment
9+
/// List the canisters in an environment.
10+
///
11+
/// Prints canister names, one per line. Use --json for machine-readable output
12+
/// (returns {"canisters": ["name1", "name2", ...]})
1013
#[derive(Debug, Args)]
1114
pub(crate) struct ListArgs {
1215
#[command(flatten)]

crates/icp-cli/src/commands/canister/settings/show.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ use crate::commands::{
66
canister::status::{self, StatusArgs, StatusArgsOptions},
77
};
88

9-
/// Show the status of a canister.
9+
/// Show the status of a canister, including its settings.
1010
///
11+
/// A canister must always be specified (no default-to-all behaviour).
1112
/// By default this queries the status endpoint of the management canister.
1213
/// If the caller is not a controller, falls back on fetching public
1314
/// information from the state tree.
1415
#[derive(Debug, Args)]
1516
pub(crate) struct ShowArgs {
16-
/// canister name or principal to target.
17-
/// When using a name, an enviroment must be specified.
17+
/// Canister name or principal to target.
18+
/// When using a name, an environment must be specified.
1819
pub(crate) canister: args::Canister,
1920

2021
#[command(flatten)]

crates/icp-cli/src/commands/canister/settings/update.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ impl ControllerOpt {
4444

4545
#[derive(Clone, Debug, Default, Args)]
4646
pub(crate) struct LogVisibilityOpt {
47+
/// Set log visibility to a fixed policy [possible values: controllers, public].
48+
/// Conflicts with --add-log-viewer, --remove-log-viewer, and --set-log-viewer.
49+
/// Use --add-log-viewer / --set-log-viewer to grant access to specific principals instead.
4750
#[arg(
4851
long,
4952
value_parser = log_visibility_parser,
@@ -53,12 +56,15 @@ pub(crate) struct LogVisibilityOpt {
5356
)]
5457
log_visibility: Option<LogVisibility>,
5558

59+
/// Add a principal to the allowed log viewers list
5660
#[arg(long, action = ArgAction::Append, conflicts_with("set_log_viewer"))]
5761
add_log_viewer: Option<Vec<Principal>>,
5862

63+
/// Remove a principal from the allowed log viewers list
5964
#[arg(long, action = ArgAction::Append, conflicts_with("set_log_viewer"))]
6065
remove_log_viewer: Option<Vec<Principal>>,
6166

67+
/// Replace the allowed log viewers list with the specified principals
6268
#[arg(long, action = ArgAction::Append)]
6369
set_log_viewer: Option<Vec<Principal>>,
6470
}
@@ -71,9 +77,11 @@ impl LogVisibilityOpt {
7177

7278
#[derive(Clone, Debug, Default, Args)]
7379
pub(crate) struct EnvironmentVariableOpt {
80+
/// Add a canister environment variable in KEY=VALUE format
7481
#[arg(long, value_parser = environment_variable_parser, action = ArgAction::Append)]
7582
add_environment_variable: Option<Vec<EnvironmentVariable>>,
7683

84+
/// Remove a canister environment variable by key name
7785
#[arg(long, action = ArgAction::Append)]
7886
remove_environment_variable: Option<Vec<String>>,
7987
}
@@ -97,6 +105,7 @@ pub(crate) struct UpdateArgs {
97105
#[command(flatten)]
98106
controllers: Option<ControllerOpt>,
99107

108+
/// Compute allocation percentage (0-100). Represents a guaranteed share of a subnet's compute capacity.
100109
#[arg(long, value_parser = compute_allocation_parser)]
101110
compute_allocation: Option<u8>,
102111

crates/icp-cli/src/commands/canister/status.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,25 @@ const E_NOT_A_CONTROLLER: &str = "IC0512";
2929
/// If the caller is not a controller, falls back on fetching public
3030
/// information from the state tree.
3131
#[derive(Debug, Args)]
32+
#[command(after_long_help = "\
33+
Examples:
34+
35+
# Status of all canisters in the local environment
36+
icp canister status
37+
38+
# Status of one canister by name
39+
icp canister status backend -e local
40+
41+
# Print only canister IDs (useful for scripting)
42+
icp canister status -i
43+
44+
# JSON output for all canisters
45+
icp canister status --json
46+
")]
3247
pub(crate) struct StatusArgs {
3348
/// An optional canister name or principal to target.
34-
/// When using a name, an enviroment must be specified.
49+
/// When using a name, an environment must be specified.
50+
/// If omitted, shows status for all canisters in the environment.
3551
pub(crate) canister: Option<args::Canister>,
3652

3753
#[command(flatten)]

crates/icp-cli/src/commands/cycles/mint.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use crate::commands::args::TokenCommandArgs;
1111
use crate::commands::parsers::parse_subaccount;
1212
use crate::operations::token::mint::mint_cycles;
1313

14-
/// Convert icp to cycles
14+
/// Convert ICP to cycles.
15+
///
16+
/// Exactly one of --icp or --cycles must be provided.
1517
#[derive(Debug, Args)]
1618
pub(crate) struct MintArgs {
1719
/// Amount of ICP to mint to cycles.

crates/icp-cli/src/commands/cycles/transfer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(crate) struct TransferArgs {
2626
#[arg(long, value_parser = parse_subaccount)]
2727
pub(crate) to_subaccount: Option<[u8; 32]>,
2828

29-
//// The subaccount to transfer from
29+
/// The subaccount to transfer cycles from
3030
#[arg(long, value_parser = parse_subaccount)]
3131
pub(crate) from_subaccount: Option<[u8; 32]>,
3232

crates/icp-cli/src/commands/environment/list.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use clap::Args;
22
use icp::context::Context;
33

4-
/// Display a list of enviroments
4+
/// List the environments defined in this project, one per line.
5+
///
6+
/// Use `icp project show` to see the fully expanded configuration including
7+
/// implicit environments (local, ic) and their network and canister assignments.
58
#[derive(Args, Debug)]
69
pub(crate) struct ListArgs;
710

crates/icp-cli/src/commands/network/start.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ use tracing::{debug, info, warn};
2020
use super::args::NetworkOrEnvironmentArgs;
2121
use icp::context::Context;
2222

23-
/// Run a given network
23+
/// Run a given network.
24+
///
25+
/// The gateway binds to port 8000 by default. To use a different port, set
26+
/// `gateway.port` in `icp.yaml`. If port 8000 is already in use by another
27+
/// icp-cli project, stop that network first:
28+
///
29+
/// icp network stop --project-root-override <path>
2430
#[derive(Args, Debug)]
2531
#[command(after_long_help = "\
2632
Examples:

crates/icp-cli/src/commands/new.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ pub struct IcpGenerateArgs {
5858
#[arg(long, action)]
5959
pub continue_on_error: bool,
6060

61-
/// If silent mode is set all variables will be extracted from the template_values_file. If a
62-
/// value is missing the project generation will fail
61+
/// Non-interactive mode: suppresses all prompts. Unset variables fall back to their
62+
/// template-defined defaults; generation fails if a required variable has no default.
63+
/// Combine with --define to supply values for variables that have no default in the template.
64+
/// Use for CI or automated/agent contexts.
6365
#[arg(long, short, requires("name"), action)]
6466
pub silent: bool,
6567

@@ -77,7 +79,9 @@ pub struct IcpGenerateArgs {
7779
#[arg(long = "gitconfig", value_parser, value_name="GITCONFIG_FILE", help_heading = heading::GIT_PARAMETERS)]
7880
pub gitconfig: Option<PathBuf>,
7981

80-
/// Define a value for use during template expansion. E.g `--define foo=bar`
82+
/// Set a template variable in KEY=VALUE format (e.g. --define project_name=my-app).
83+
/// Variable names are template-specific. Suppresses the interactive prompt for that variable.
84+
/// Required in --silent mode for any template variable that has no default value.
8185
#[arg(long, short, number_of_values = 1, value_parser, help_heading = heading::OUTPUT_PARAMETERS)]
8286
pub define: Vec<String>,
8387

docs/reference/cli.md

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ Install a built WASM to a canister on a network
314314

315315
## `icp canister list`
316316

317-
List the canisters in an environment
317+
List the canisters in an environment.
318+
319+
Prints canister names, one per line. Use --json for machine-readable output (returns {"canisters": ["name1", "name2", ...]})
318320

319321
**Usage:** `icp canister list [OPTIONS]`
320322

@@ -406,23 +408,23 @@ Commands to manage canister settings
406408

407409
###### **Subcommands:**
408410

409-
* `show` — Show the status of a canister
411+
* `show` — Show the status of a canister, including its settings
410412
* `update` — Change a canister's settings to specified values
411413
* `sync` — Synchronize a canister's settings with those defined in the project
412414

413415

414416

415417
## `icp canister settings show`
416418

417-
Show the status of a canister.
419+
Show the status of a canister, including its settings.
418420

419-
By default this queries the status endpoint of the management canister. If the caller is not a controller, falls back on fetching public information from the state tree.
421+
A canister must always be specified (no default-to-all behaviour). By default this queries the status endpoint of the management canister. If the caller is not a controller, falls back on fetching public information from the state tree.
420422

421423
**Usage:** `icp canister settings show [OPTIONS] <CANISTER>`
422424

423425
###### **Arguments:**
424426

425-
* `<CANISTER>`canister name or principal to target. When using a name, an enviroment must be specified
427+
* `<CANISTER>`Canister name or principal to target. When using a name, an environment must be specified
426428

427429
###### **Options:**
428430

@@ -461,19 +463,19 @@ Change a canister's settings to specified values
461463
* `--set-controller <SET_CONTROLLER>` — Replace the canister's controller list with the specified principals.
462464

463465
Warning: This removes all existing controllers not in the new list. If you don't include yourself, you will lose control of the canister.
464-
* `--compute-allocation <COMPUTE_ALLOCATION>`
466+
* `--compute-allocation <COMPUTE_ALLOCATION>` — Compute allocation percentage (0-100). Represents a guaranteed share of a subnet's compute capacity
465467
* `--memory-allocation <MEMORY_ALLOCATION>` — Memory allocation in bytes. Supports suffixes: kb, kib, mb, mib, gb, gib (e.g. "4gib" or "2.5kb")
466468
* `--freezing-threshold <FREEZING_THRESHOLD>` — Freezing threshold. Controls how long a canister can be inactive before being frozen. Supports duration suffixes: s (seconds), m (minutes), h (hours), d (days), w (weeks). A bare number is treated as seconds
467469
* `--reserved-cycles-limit <RESERVED_CYCLES_LIMIT>` — Upper limit on cycles reserved for future resource payments. Memory allocations that would push the reserved balance above this limit will fail. Supports suffixes: k (thousand), m (million), b (billion), t (trillion)
468470
* `--wasm-memory-limit <WASM_MEMORY_LIMIT>` — Wasm memory limit in bytes. Supports suffixes: kb, kib, mb, mib, gb, gib (e.g. "4gib" or "2.5kb")
469471
* `--wasm-memory-threshold <WASM_MEMORY_THRESHOLD>` — Wasm memory threshold in bytes. Supports suffixes: kb, kib, mb, mib, gb, gib (e.g. "4gib" or "2.5kb")
470472
* `--log-memory-limit <LOG_MEMORY_LIMIT>` — Log memory limit in bytes (max 2 MiB). Oldest logs are purged when usage exceeds this value. Supports suffixes: kb, kib, mb, mib (e.g. "2mib" or "256kib"). Canister default is 4096 bytes
471-
* `--log-visibility <LOG_VISIBILITY>`
472-
* `--add-log-viewer <ADD_LOG_VIEWER>`
473-
* `--remove-log-viewer <REMOVE_LOG_VIEWER>`
474-
* `--set-log-viewer <SET_LOG_VIEWER>`
475-
* `--add-environment-variable <ADD_ENVIRONMENT_VARIABLE>`
476-
* `--remove-environment-variable <REMOVE_ENVIRONMENT_VARIABLE>`
473+
* `--log-visibility <LOG_VISIBILITY>` — Set log visibility to a fixed policy [possible values: controllers, public]. Conflicts with --add-log-viewer, --remove-log-viewer, and --set-log-viewer. Use --add-log-viewer / --set-log-viewer to grant access to specific principals instead
474+
* `--add-log-viewer <ADD_LOG_VIEWER>` — Add a principal to the allowed log viewers list
475+
* `--remove-log-viewer <REMOVE_LOG_VIEWER>` — Remove a principal from the allowed log viewers list
476+
* `--set-log-viewer <SET_LOG_VIEWER>` — Replace the allowed log viewers list with the specified principals
477+
* `--add-environment-variable <ADD_ENVIRONMENT_VARIABLE>` — Add a canister environment variable in KEY=VALUE format
478+
* `--remove-environment-variable <REMOVE_ENVIRONMENT_VARIABLE>` — Remove a canister environment variable by key name
477479
* `--proxy <PROXY>` — Principal of a proxy canister to route the management canister calls through
478480

479481

@@ -678,9 +680,24 @@ By default this queries the status endpoint of the management canister. If the c
678680

679681
**Usage:** `icp canister status [OPTIONS] [CANISTER]`
680682

683+
Examples:
684+
685+
# Status of all canisters in the local environment
686+
icp canister status
687+
688+
# Status of one canister by name
689+
icp canister status backend -e local
690+
691+
# Print only canister IDs (useful for scripting)
692+
icp canister status -i
693+
694+
# JSON output for all canisters
695+
icp canister status --json
696+
697+
681698
###### **Arguments:**
682699

683-
* `<CANISTER>` — An optional canister name or principal to target. When using a name, an enviroment must be specified
700+
* `<CANISTER>` — An optional canister name or principal to target. When using a name, an environment must be specified. If omitted, shows status for all canisters in the environment
684701

685702
###### **Options:**
686703

@@ -744,7 +761,7 @@ Mint and manage cycles
744761
###### **Subcommands:**
745762

746763
* `balance` — Display the cycles balance
747-
* `mint` — Convert icp to cycles
764+
* `mint` — Convert ICP to cycles
748765
* `transfer` — Transfer cycles to another principal
749766

750767

@@ -769,7 +786,9 @@ Display the cycles balance
769786

770787
## `icp cycles mint`
771788

772-
Convert icp to cycles
789+
Convert ICP to cycles.
790+
791+
Exactly one of --icp or --cycles must be provided.
773792

774793
**Usage:** `icp cycles mint [OPTIONS]`
775794

@@ -801,7 +820,7 @@ Transfer cycles to another principal
801820
###### **Options:**
802821

803822
* `--to-subaccount <TO_SUBACCOUNT>` — The subaccount to transfer to (only if the receiver is a principal)
804-
* `--from-subaccount <FROM_SUBACCOUNT>`
823+
* `--from-subaccount <FROM_SUBACCOUNT>` — The subaccount to transfer cycles from
805824
* `-n`, `--network <NETWORK>` — Name or URL of the network to target, conflicts with environment argument
806825
* `-k`, `--root-key <ROOT_KEY>` — The root key to use if connecting to a network by URL. Required when using `--network <URL>`
807826
* `-e`, `--environment <ENVIRONMENT>` — Override the environment to connect to. By default, the local environment is used
@@ -877,13 +896,15 @@ Show information about the current project environments
877896

878897
###### **Subcommands:**
879898

880-
* `list`Display a list of enviroments
899+
* `list`List the environments defined in this project, one per line
881900

882901

883902

884903
## `icp environment list`
885904

886-
Display a list of enviroments
905+
List the environments defined in this project, one per line.
906+
907+
Use `icp project show` to see the fully expanded configuration including implicit environments (local, ic) and their network and canister assignments.
887908

888909
**Usage:** `icp environment list`
889910

@@ -1172,7 +1193,11 @@ Examples:
11721193

11731194
## `icp network start`
11741195

1175-
Run a given network
1196+
Run a given network.
1197+
1198+
The gateway binds to port 8000 by default. To use a different port, set `gateway.port` in `icp.yaml`. If port 8000 is already in use by another icp-cli project, stop that network first:
1199+
1200+
icp network stop --project-root-override <path>
11761201

11771202
**Usage:** `icp network start [OPTIONS] [NAME]`
11781203

@@ -1328,11 +1353,11 @@ Under the hood templates are generated with `cargo-generate`. See the cargo-gene
13281353
* `-f`, `--force` — Don't convert the project name to kebab-case before creating the directory. Note that `icp-cli` won't overwrite an existing directory, even if `--force` is given
13291354
* `-q`, `--quiet` — Opposite of verbose, suppresses errors & warning in output Conflicts with --debug, and requires the use of --continue-on-error
13301355
* `--continue-on-error` — Continue if errors in templates are encountered
1331-
* `-s`, `--silent`If silent mode is set all variables will be extracted from the template_values_file. If a value is missing the project generation will fail
1356+
* `-s`, `--silent`Non-interactive mode: suppresses all prompts. Unset variables fall back to their template-defined defaults; generation fails if a required variable has no default. Combine with --define to supply values for variables that have no default in the template. Use for CI or automated/agent contexts
13321357
* `--vcs <VCS>` — Specify the VCS used to initialize the generated template
13331358
* `-i`, `--identity <IDENTITY>` — Use a different ssh identity
13341359
* `--gitconfig <GITCONFIG_FILE>` — Use a different gitconfig file, if omitted the usual $HOME/.gitconfig will be used
1335-
* `-d`, `--define <DEFINE>`Define a value for use during template expansion. E.g `--define foo=bar`
1360+
* `-d`, `--define <DEFINE>`Set a template variable in KEY=VALUE format (e.g. --define project_name=my-app). Variable names are template-specific. Suppresses the interactive prompt for that variable. Required in --silent mode for any template variable that has no default value
13361361
* `--init` — Generate the template directly into the current dir. No subfolder will be created and no vcs is initialized
13371362
* `--destination <PATH>` — Generate the template directly at the given path
13381363
* `--force-git-init` — Will enforce a fresh git init on the generated project

0 commit comments

Comments
 (0)