pub struct ParameterConfig {
pub name: String,
pub nargs: Nargs,
pub multiple: bool,
pub is_eager: bool,
pub expose_value: bool,
pub required: bool,
pub envvar: Option<Vec<String>>,
pub help: Option<String>,
pub hidden: bool,
pub metavar: Option<String>,
pub deprecated: Option<DeprecationInfo>,
pub callback: Option<ParameterCallback>,
}Expand description
Common configuration for all parameter types.
This struct holds the shared settings between Options and Arguments. It uses a builder pattern for convenient construction.
Fields§
§name: StringThe parameter name.
nargs: NargsNumber of arguments consumed.
multiple: boolWhether the parameter can be specified multiple times.
is_eager: boolWhether this parameter should be processed before others.
expose_value: boolWhether this parameter’s value is exposed in ctx.params.
required: boolWhether this parameter is required.
envvar: Option<Vec<String>>Environment variable name(s) for this parameter.
help: Option<String>Help text for this parameter.
Whether this parameter is hidden from help.
metavar: Option<String>Custom metavar for help text.
deprecated: Option<DeprecationInfo>Whether this parameter is deprecated.
callback: Option<ParameterCallback>Optional callback invoked after conversion.
Implementations§
Source§impl ParameterConfig
impl ParameterConfig
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Create a new parameter configuration with the given name.
Sourcepub fn multiple(self, multiple: bool) -> Self
pub fn multiple(self, multiple: bool) -> Self
Set whether the parameter can be specified multiple times.
Sourcepub fn eager(self, eager: bool) -> Self
pub fn eager(self, eager: bool) -> Self
Set whether this parameter should be processed before others.
Sourcepub fn expose_value(self, expose: bool) -> Self
pub fn expose_value(self, expose: bool) -> Self
Set whether this parameter’s value is exposed in ctx.params.
Sourcepub fn envvar(self, var: impl Into<String>) -> Self
pub fn envvar(self, var: impl Into<String>) -> Self
Set a single environment variable for this parameter.
Sourcepub fn envvars(self, vars: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn envvars(self, vars: impl IntoIterator<Item = impl Into<String>>) -> Self
Set multiple environment variables for this parameter.
Set whether this parameter is hidden from help.
Sourcepub fn callback(self, callback: ParameterCallback) -> Self
pub fn callback(self, callback: ParameterCallback) -> Self
Set a callback invoked after conversion.
Sourcepub fn deprecated(self, deprecated: bool) -> Self
pub fn deprecated(self, deprecated: bool) -> Self
Mark this parameter as deprecated.
Sourcepub fn deprecated_with_message(self, message: impl Into<String>) -> Self
pub fn deprecated_with_message(self, message: impl Into<String>) -> Self
Mark this parameter as deprecated with a custom message.
Sourcepub fn validate(&self) -> Result<(), ClickError>
pub fn validate(&self) -> Result<(), ClickError>
Validate the configuration.
Returns an error if the configuration is invalid.
Trait Implementations§
Source§impl Clone for ParameterConfig
impl Clone for ParameterConfig
Source§fn clone(&self) -> ParameterConfig
fn clone(&self) -> ParameterConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more