pub struct OptSpec {
pub name: &'static str,
pub short: Option<char>,
pub ty: &'static str,
pub doc: &'static str,
pub env: Option<&'static str>,
pub default: Option<&'static str>,
pub example: Option<&'static str>,
}Expand description
Specification for Opt.
Note that noargs does not support options with only short names.
Fields§
§name: &'static strOption long name (usually kebab-case).
short: Option<char>Option short name.
ty: &'static strValue type.
doc: &'static strDocumentation.
env: Option<&'static str>Environment variable name.
If a non-empty value is set for this environment variable,
it will be used as the value of this option when the option is not specified in RawArgs.
default: Option<&'static str>Default value.
example: Option<&'static str>Example value (if this is set, the option is considered to be requried when generating the help text).
This is only used if RawArgs::metadata().help_mode is true.
Implementations§
Source§impl OptSpec
impl OptSpec
Sourcepub const fn new(name: &'static str) -> Self
pub const fn new(name: &'static str) -> Self
Makes an OptSpec instance with a specified name (equivalent to noargs::opt(name)).
Sourcepub const fn short(self, name: char) -> Self
pub const fn short(self, name: char) -> Self
Updates the value of OptSpec::short.
Sourcepub const fn ty(self, value_type: &'static str) -> Self
pub const fn ty(self, value_type: &'static str) -> Self
Updates the value of OptSpec::ty.
Sourcepub const fn doc(self, doc: &'static str) -> Self
pub const fn doc(self, doc: &'static str) -> Self
Updates the value of OptSpec::doc.
Sourcepub const fn env(self, variable_name: &'static str) -> Self
pub const fn env(self, variable_name: &'static str) -> Self
Updates the value of OptSpec::env.
Sourcepub const fn default(self, default: &'static str) -> Self
pub const fn default(self, default: &'static str) -> Self
Updates the value of OptSpec::default.
Sourcepub const fn example(self, example: &'static str) -> Self
pub const fn example(self, example: &'static str) -> Self
Updates the value of OptSpec::example.