Lines Matching refs:name
72 name: Str,
86 aliases: Vec<(Str, bool)>, // (name, visible)
87 short_flag_aliases: Vec<(char, bool)>, // (name, visible)
88 long_flag_aliases: Vec<(Str, bool)>, // (name, visible)
115 /// It is common, but not required, to use binary name as the `name`. This
116 /// name will only be displayed to the user when they request to print
128 pub fn new(name: impl Into<Str>) -> Self {
133 fn new_inner(name: Str) -> Command {
135 name,
140 new_inner(name.into())
280 pub fn mut_subcommand<F>(mut self, name: impl AsRef<str>, f: F) -> Self
284 let name = name.as_ref();
285 let pos = self.subcommands.iter().position(|s| s.name == name);
290 panic!("Command `{name}` is undefined")
371 /// A subcommand's [`Command::name`] will be used for:
553 /// **NOTE:** The first argument will be parsed as the binary name unless
591 /// **NOTE:** The first argument will be parsed as the binary name unless
636 /// **NOTE:** The first argument will be parsed as the binary name unless
679 debug!("Command::try_get_matches_from_mut: Clearing name and bin_name so that displayed command name starts with applet name");
680 self.name = "".into();
687 // Get the name of the program (argument 1 of env::args()) and determine the
695 if let Some(name) = raw_args.next_os(&mut cursor) {
696 let p = Path::new(name);
920 /// Specifies that the parser should not assume the first argument passed is the binary name.
1393 /// (Re)Sets the program's name.
1401 /// .name("foo");
1406 pub fn name(mut self, name: impl Into<Str>) -> Self {
1407 self.name = name.into();
1411 /// Overrides the runtime-determined name of the binary for help and error messages.
1413 /// This should only be used when absolutely necessary, such as when the binary name for your
1419 /// **NOTE:** This *does not* change or set the name of the binary file on
1420 /// disk. It only changes what clap thinks the name is for the purposes of
1432 pub fn bin_name(mut self, name: impl IntoResettable<String>) -> Self {
1433 self.bin_name = name.into_resettable().into_option();
1437 /// Overrides the runtime-determined display name of the program for help and error messages.
1448 pub fn display_name(mut self, name: impl IntoResettable<String>) -> Self {
1449 self.display_name = name.into_resettable().into_option();
1746 /// * `{name}` - Display name for the (sub-)command.
1747 /// * `{bin}` - Binary name.(deprecated)
1775 /// .help_template("{name} ({version}) - {usage}")
1786 /// {before-help}{name} {version}
1875 /// When this method is used, `name` is removed from the CLI, and `target`
1877 /// `target` instead of `name`.
1983 name: impl Into<Str>,
1987 .insert(name.into(), target.into_iter().map(Into::into).collect());
2243 /// This allows the subcommand to be accessed via *either* the original name, or this given
2253 /// search for the original name and not all aliases.
2267 pub fn alias(mut self, name: impl IntoResettable<Str>) -> Self {
2268 if let Some(name) = name.into_resettable().into_option() {
2269 self.aliases.push((name, false));
2293 pub fn short_flag_alias(mut self, name: impl IntoResettable<char>) -> Self {
2294 if let Some(name) = name.into_resettable().into_option() {
2295 debug_assert!(name != '-', "short alias name cannot be `-`");
2296 self.short_flag_aliases.push((name, false));
2320 pub fn long_flag_alias(mut self, name: impl IntoResettable<Str>) -> Self {
2321 if let Some(name) = name.into_resettable().into_option() {
2322 self.long_flag_aliases.push((name, false));
2331 /// This allows the subcommand to be accessed via *either* the original name or any of the
2341 /// search for the original name and not all aliases.
2386 debug_assert!(s != '-', "short alias name cannot be `-`");
2422 /// original name or the given alias. This is more efficient and easier
2433 /// search for the original name and not all aliases.
2447 pub fn visible_alias(mut self, name: impl IntoResettable<Str>) -> Self {
2448 if let Some(name) = name.into_resettable().into_option() {
2449 self.aliases.push((name, true));
2476 pub fn visible_short_flag_alias(mut self, name: impl IntoResettable<char>) -> Self {
2477 if let Some(name) = name.into_resettable().into_option() {
2478 debug_assert!(name != '-', "short alias name cannot be `-`");
2479 self.short_flag_aliases.push((name, true));
2506 pub fn visible_long_flag_alias(mut self, name: impl IntoResettable<Str>) -> Self {
2507 if let Some(name) = name.into_resettable().into_option() {
2508 self.long_flag_aliases.push((name, true));
2518 /// original name or any of the given aliases. This is more efficient and easier
2529 /// search for the original name and not all aliases.
2567 debug_assert!(s != '-', "short alias name cannot be `-`");
2616 /// // alphabetically by name. Subcommands
2728 /// // string argument name
2772 /// // string argument name
2794 /// // string argument name
2956 /// Multiple-personality program dispatched on the binary name (`argv[0]`)
2960 /// and decides which applet to run based on the name of the file.
2971 /// - `argv[0]` to be stripped to the base name and parsed as the first argument, as if
2987 /// get the unrecognized binary name.
2990 /// the command name in incompatible ways.
3002 /// and which behaviour to use is based on the executable file name.
3008 /// The name of the cmd is essentially unused
3009 /// and may be the same as the name of a subcommand.
3038 /// or there may already be a command of that name installed.
3058 /// // When called from the executable's canonical name
3080 /// Sets the value name used for subcommands when printing usage and help.
3217 /// Get the name of the binary.
3223 /// Get the name of the binary.
3229 /// Set binary name. Uses `&mut self` instead of `self`.
3230 pub fn set_bin_name(&mut self, name: impl Into<String>) {
3231 self.bin_name = Some(name.into());
3234 /// Get the name of the cmd.
3237 self.name.as_str()
3243 &self.name
3394 /// Returns the subcommand value name.
3424 /// Find subcommand such that its name or one of aliases equals `name`.
3428 pub fn find_subcommand(&self, name: impl AsRef<std::ffi::OsStr>) -> Option<&Command> {
3429 let name = name.as_ref();
3430 self.get_subcommands().find(|s| s.aliases_to(name))
3433 /// Find subcommand such that its name or one of aliases equals `name`, returning
3440 name: impl AsRef<std::ffi::OsStr>,
3442 let name = name.as_ref();
3443 self.get_subcommands_mut().find(|s| s.aliases_to(name))
3829 debug!("Command::_build: name={:?}", self.get_name());
3927 pub(crate) fn _build_subcommand(&mut self, name: &str) -> Option<&mut Self> {
3943 let sc = some!(self.subcommands.iter_mut().find(|s| s.name == name));
3945 // Display subcommand name, short and long in usage
3947 sc_names.push_str(sc.name.as_str());
3969 // bin_name should be parent's bin_name + [<reqs>] + the sc's name separated by
3975 &*sc.name
3979 sc.name, bin_name
3987 self.display_name.as_deref().unwrap_or(&self.name)
3997 &*sc.name
4001 sc.name, display_name
4033 self.bin_name.as_deref().unwrap_or(&self.name)
4042 // Display subcommand name, short and long in usage
4044 sc_names.push_str(sc.name.as_str());
4062 sc.name, usage_name
4068 sc.name, sc.usage_name
4077 &*sc.name
4081 sc.name, bin_name
4087 sc.name, sc.bin_name
4095 self.display_name.as_deref().unwrap_or(&self.name)
4105 &*sc.name
4109 sc.name, display_name
4115 sc.name, sc.display_name
4138 self.name,
4167 debug!("Command::_propagate_global_args:{}", self.name);
4202 debug!("Command::_propagate:{}", self.name);
4233 self.name, expand_help_tree
4311 let mut cmd = Command::new(self.name.clone())
4405 .any(|sc| sc.name != "help" && !sc.is_set(AppSettings::Hidden))
4408 /// Check if this subcommand can be referred to as `name`. In other words,
4409 /// check if `name` is the name of this subcommand or is one of its aliases.
4411 pub(crate) fn aliases_to(&self, name: impl AsRef<std::ffi::OsStr>) -> bool {
4412 let name = name.as_ref();
4413 self.get_name() == name || self.get_all_aliases().any(|alias| alias == name)
4416 /// Check if this subcommand can be referred to as `name`. In other words,
4417 /// check if `name` is the name of this short flag subcommand or is one of its short flag aliases.
4424 /// Check if this subcommand can be referred to as `name`. In other words,
4425 /// check if `name` is the name of this long flag subcommand or is one of its long flag aliases.
4459 let name = sc.get_name();
4461 std::iter::once(name).chain(aliases)
4542 /// Find a flag subcommand name by short flag or an alias
4549 /// Find a flag subcommand name by long flag or an alias
4628 name: Default::default(),
4685 write!(f, "{}", self.name)