Skip to main content

Module parser

Module parser 

Source
Available on crate feature cli only.
Expand description

The parser rules every CLI built on ctl-core keeps: -h / --help, the help subcommand, and -V / --version stay on, and a repeated flag takes its last value.

apply_defaults sets those rules on a Clap command, and verify is the test a CLI runs over its own parser.

ctl-core declares -h / --help and help itself, so they work without Clap’s help feature, which ctl-core leaves off. Clap turns both off without that feature (clap_builder 4.6.6, Command::_build_self). ctl-core renders the help, so Clap’s help writer is never needed. A plain Cli::parse() that skips ctl-core’s entry point gets Clap’s minimal output for --help and no help subcommand.

use clap::Parser;

#[derive(Parser)]
#[command(version, about = "toy")]
struct Cli {}

ctl_core::parser::verify::<Cli>();

Functions§

apply_defaults
Apply ctl-core’s parser rules to a Clap command and return it.
verify
Check a CLI’s parser: Clap’s recommended Command::debug_assert, and that help and version stay on.