diff --git a/README.md b/README.md index a8f28569c..a7201605a 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,8 @@ There are a few bugs in Zebra that we're still working on fixing: - Experimental Tor support is disabled until [`arti-client` upgrades to `x25519-dalek` 2.0.0 or later](https://github.com/ZcashFoundation/zebra/issues/5492) - This happens due to a Rust dependency conflict, which can only be resolved by changing the dependencies of `x25519-dalek` +- Output of `help`, `--help` flag, and usage of invalid commands or options are inconsistent. Reports of these issues can be found [here](https://github.com/ZcashFoundation/zebra/issues/5502) and are planned to be fixed in the context of [upgrading Abscissa](https://github.com/ZcashFoundation/zebra/issues/5502). + ## Future Work Performance and Reliability: diff --git a/zebrad/src/application.rs b/zebrad/src/application.rs index 69b5734c0..b07c41c19 100644 --- a/zebrad/src/application.rs +++ b/zebrad/src/application.rs @@ -376,7 +376,7 @@ impl Application for ZebradApp { let default_filter = command .command .as_ref() - .map(|zcmd| zcmd.default_tracing_filter(command.verbose)) + .map(|zcmd| zcmd.default_tracing_filter(command.verbose, command.help)) .unwrap_or("warn"); let is_server = command .command diff --git a/zebrad/src/application/entry_point.rs b/zebrad/src/application/entry_point.rs index bbcff6cb8..16f262d13 100644 --- a/zebrad/src/application/entry_point.rs +++ b/zebrad/src/application/entry_point.rs @@ -42,6 +42,13 @@ pub struct EntryPoint { impl EntryPoint { /// Borrow the underlying command type fn command(&self) -> &ZebradCmd { + if self.help { + let _ = Usage::for_command::().print_info(); + let _ = Usage::for_command::().print_usage(); + let _ = Usage::for_command::().print_usage(); + std::process::exit(0); + } + self.command .as_ref() .expect("Some(ZebradCmd::Start(StartCmd::default()) as default value") diff --git a/zebrad/src/commands.rs b/zebrad/src/commands.rs index c53d177d2..a306a5ab8 100644 --- a/zebrad/src/commands.rs +++ b/zebrad/src/commands.rs @@ -42,7 +42,9 @@ pub enum ZebradCmd { Generate(GenerateCmd), /// The `help` subcommand - #[options(help = "get usage information")] + #[options(help = "get usage information, \ + use help for subcommand usage information, \ + or --help flag to see top-level options")] Help(Help), /// The `start` subcommand @@ -78,7 +80,7 @@ impl ZebradCmd { /// Returns the default log level for this command, based on the `verbose` command line flag. /// /// Some commands need to be quiet by default. - pub(crate) fn default_tracing_filter(&self, verbose: bool) -> &'static str { + pub(crate) fn default_tracing_filter(&self, verbose: bool, help: bool) -> &'static str { let only_show_warnings = match self { // Commands that generate quiet output by default. // This output: @@ -90,7 +92,8 @@ impl ZebradCmd { CopyState(_) | Download(_) | Start(_) => false, }; - if only_show_warnings && !verbose { + // set to warn so that usage info is printed without info-level logs from component registration + if help || (only_show_warnings && !verbose) { "warn" } else if only_show_warnings || !verbose { "info"