Skip to content

Wrong help message is displayed when some experimental flag are provided

When Arti is built providing experimental flags that enable state management subcommands (onion-service-service, hsc and onion-service-cli-extra), the wrong help message is displayed. For example:

Using hsc flag, this is the output of the command arti/arti --help:

Wrong output
The hsc subcommands the arti CLI will be augmented with

Usage: arti <SUBCOMMAND> [OPTIONS]

Commands:
  proxy  Run Arti in SOCKS proxy mode, proxying connections through the Tor network.
  hsc    Run state management commands for an Arti hidden service client
  help   Print this message or the help of the given subcommand(s)

Options:
  -c, --config <FILE>                 Specify which config file(s) to read. Defaults to [File("/home/hj/.config/arti/arti.toml"), Dir("/home/hj/.config/arti/arti.d/")]
  -o <KEY=VALUE>                      Override config file parameters, using TOML-like syntax.
  -l, --log-level <LEVEL>             Override the log level (usually one of 'trace', 'debug', 'info', 'warn', 'error').
      --disable-fs-permission-checks  Don't check permissions on the files we use.
  -h, --help                          Print help
  -V, --version                       Print version
Expected help message
A Rust Tor implementation.

Usage: arti <SUBCOMMAND> [OPTIONS]

Commands:
  proxy  Run Arti in SOCKS proxy mode, proxying connections through the Tor network.
  hsc    Run state management commands for an Arti hidden service client
  help   Print this message or the help of the given subcommand(s)

Options:
  -c, --config <FILE>                 Specify which config file(s) to read. Defaults to [File("/home/hj/.config/arti/arti.toml"), Dir("/home/hj/.config/arti/arti.d/")]
  -o <KEY=VALUE>                      Override config file parameters, using TOML-like syntax.
  -l, --log-level <LEVEL>             Override the log level (usually one of 'trace', 'debug', 'info', 'warn', 'error').
      --disable-fs-permission-checks  Don't check permissions on the files we use.
  -h, --help                          Print help
  -V, --version                       Print version

I think the problem lies here: instead of augmenting clap_app: clap::Command with subcommands::hsc::HscSubcommands, subcommands::hsc::HscSubcommands is augmented with clap_app, then a new clap_app variable (that shadows the first one) is produced, at this point the description of subcommands::hsc::HscSubcommands is displayed instead of the correct message.

It could be a good idea to write trycmd integration tests for arti --help when the aforementioned flags are provided.

Edited by hjrgrn