pub struct CommandBuilder { /* private fields */ }Expand description
Builder for creating Command instances.
Use Command::new to create a builder, then chain methods to configure
the command, and finally call build to create
the command.
Implementations§
Source§impl CommandBuilder
impl CommandBuilder
Sourcepub fn callback<F>(self, f: F) -> Self
pub fn callback<F>(self, f: F) -> Self
Set the callback function for this command.
The callback receives a reference to the Context and should return
Ok(()) on success or a ClickError on failure.
Sourcepub fn option(self, opt: ClickOption) -> Self
pub fn option(self, opt: ClickOption) -> Self
Add an option to this command.
Sourcepub fn short_help(self, short_help: &str) -> Self
pub fn short_help(self, short_help: &str) -> Self
Set the short help text for command listings.
Sourcepub fn options_metavar(self, metavar: &str) -> Self
pub fn options_metavar(self, metavar: &str) -> Self
Set the options metavar (default: “[OPTIONS]”).
Sourcepub fn add_help_option(self, add: bool) -> Self
pub fn add_help_option(self, add: bool) -> Self
Set whether to add a –help option (default: true).
Sourcepub fn help_option(self, opt: ClickOption) -> Self
pub fn help_option(self, opt: ClickOption) -> Self
Override the automatically generated help option.
This lets you customize the help option names (e.g. -h, --help) and
its help text while keeping it eager.
Setting a custom help option implicitly enables add_help_option.
Sourcepub fn no_args_is_help(self, value: bool) -> Self
pub fn no_args_is_help(self, value: bool) -> Self
Set whether to show help if no args provided (default: false).
Hide this command from help output.
Sourcepub fn deprecated(self, message: &str) -> Self
pub fn deprecated(self, message: &str) -> Self
Mark this command as deprecated.
Pass an empty string for a generic deprecation message, or a custom message for more details.
Sourcepub fn allow_extra_args(self, allow: bool) -> Self
pub fn allow_extra_args(self, allow: bool) -> Self
Set whether extra arguments are allowed.
Sourcepub fn allow_interspersed_args(self, allow: bool) -> Self
pub fn allow_interspersed_args(self, allow: bool) -> Self
Set whether interspersed arguments are allowed.
Sourcepub fn ignore_unknown_options(self, ignore: bool) -> Self
pub fn ignore_unknown_options(self, ignore: bool) -> Self
Set whether unknown options should be ignored.