fix(zebrad) print usage info for --help flag (#5634)
* print usage info for --help flag * update known issues and help command's help text * Update README.md Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com> * updates README Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
This commit is contained in:
parent
bd54a2f40e
commit
a2f2a1402e
|
@ -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)
|
- 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`
|
- 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
|
## Future Work
|
||||||
|
|
||||||
Performance and Reliability:
|
Performance and Reliability:
|
||||||
|
|
|
@ -376,7 +376,7 @@ impl Application for ZebradApp {
|
||||||
let default_filter = command
|
let default_filter = command
|
||||||
.command
|
.command
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|zcmd| zcmd.default_tracing_filter(command.verbose))
|
.map(|zcmd| zcmd.default_tracing_filter(command.verbose, command.help))
|
||||||
.unwrap_or("warn");
|
.unwrap_or("warn");
|
||||||
let is_server = command
|
let is_server = command
|
||||||
.command
|
.command
|
||||||
|
|
|
@ -42,6 +42,13 @@ pub struct EntryPoint {
|
||||||
impl EntryPoint {
|
impl EntryPoint {
|
||||||
/// Borrow the underlying command type
|
/// Borrow the underlying command type
|
||||||
fn command(&self) -> &ZebradCmd {
|
fn command(&self) -> &ZebradCmd {
|
||||||
|
if self.help {
|
||||||
|
let _ = Usage::for_command::<EntryPoint>().print_info();
|
||||||
|
let _ = Usage::for_command::<EntryPoint>().print_usage();
|
||||||
|
let _ = Usage::for_command::<ZebradCmd>().print_usage();
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
self.command
|
self.command
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Some(ZebradCmd::Start(StartCmd::default()) as default value")
|
.expect("Some(ZebradCmd::Start(StartCmd::default()) as default value")
|
||||||
|
|
|
@ -42,7 +42,9 @@ pub enum ZebradCmd {
|
||||||
Generate(GenerateCmd),
|
Generate(GenerateCmd),
|
||||||
|
|
||||||
/// The `help` subcommand
|
/// The `help` subcommand
|
||||||
#[options(help = "get usage information")]
|
#[options(help = "get usage information, \
|
||||||
|
use help <subcommand> for subcommand usage information, \
|
||||||
|
or --help flag to see top-level options")]
|
||||||
Help(Help<Self>),
|
Help(Help<Self>),
|
||||||
|
|
||||||
/// The `start` subcommand
|
/// The `start` subcommand
|
||||||
|
@ -78,7 +80,7 @@ impl ZebradCmd {
|
||||||
/// Returns the default log level for this command, based on the `verbose` command line flag.
|
/// Returns the default log level for this command, based on the `verbose` command line flag.
|
||||||
///
|
///
|
||||||
/// Some commands need to be quiet by default.
|
/// 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 {
|
let only_show_warnings = match self {
|
||||||
// Commands that generate quiet output by default.
|
// Commands that generate quiet output by default.
|
||||||
// This output:
|
// This output:
|
||||||
|
@ -90,7 +92,8 @@ impl ZebradCmd {
|
||||||
CopyState(_) | Download(_) | Start(_) => false,
|
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"
|
"warn"
|
||||||
} else if only_show_warnings || !verbose {
|
} else if only_show_warnings || !verbose {
|
||||||
"info"
|
"info"
|
||||||
|
|
Loading…
Reference in New Issue