Lines Matching defs:subcommand
49 /// - [Subcommand-specific Settings][crate::Command#subcommand-specific-settings]
252 /// Allows one to mutate a [`Command`] after it's been added as a subcommand.
259 /// If the subcommand is undefined
267 /// .subcommand(Command::new("bar"))
272 /// // Since we disabled the help flag on the "bar" subcommand, this should err.
365 /// Adds a subcommand to the list of valid possibilities.
371 /// A subcommand's [`Command::name`] will be used for:
373 /// - Programmatically looking up the subcommand
380 /// .subcommand(Command::new("config")
387 pub fn subcommand(self, subcmd: impl Into<Command>) -> Self {
419 self = self.subcommand(subcmd);
677 debug!("Command::try_get_matches_from_mut: Reinserting command into arguments so subcommand parser matches it");
908 // before parsing incase we run into a subcommand
1146 /// .subcommand(Command::new("test"))
1152 /// [`subcommands`]: crate::Command::subcommand()
1208 /// Disables the `help` [`subcommand`].
1216 /// // Normally, creating a subcommand causes a `help` subcommand to automatically
1218 /// .subcommand(Command::new("test"))
1226 /// [`subcommand`]: crate::Command::subcommand()
1347 /// Allow partial matches of [subcommand] names and their [aliases].
1349 /// For example, to match a subcommand named `test`, one could use `t`, `te`, `tes`, and
1353 /// to `test` there could not also be a subcommand or alias `temp` because both start with `te`
1369 /// .subcommand(Command::new("test"))
1376 /// [subcommand]: crate::Command::subcommand()
1513 /// more in depth about how this subcommand really works. It may take about
1871 /// Replaces an argument or subcommand used on the CLI at runtime with other arguments or subcommands.
1885 /// We'll start with the "subcommand short" example. In this example, let's
1886 /// assume we have a program with a subcommand `module` which can be invoked
1887 /// via `cmd module`. Now let's also assume `module` also has a subcommand
1892 /// We *could* create another sibling subcommand to `module` called
1893 /// `install`, but then we would need to manage another subcommand and manually
1904 /// .subcommand(Command::new("module")
1905 /// .subcommand(Command::new("install")))
2003 /// [`subcommands`]: crate::Command::subcommand()
2088 /// // Assume there is an external subcommand named "subcmd"
2106 /// // Assume there is an external subcommand named "subcmd"
2125 /// // Assume there is an external subcommand named "subcmd"
2144 /// // Assume there is an external subcommand named "subcmd"
2172 /// Sets the short version of the subcommand flag without the preceding `-`.
2174 /// Allows the subcommand to be used as if it were an [`Arg::short`].
2181 /// .subcommand(
2203 /// Sets the long version of the subcommand flag without the preceding `--`.
2205 /// Allows the subcommand to be used as if it were an [`Arg::long`].
2218 /// .subcommand(
2241 /// Sets a hidden alias to this subcommand.
2243 /// This allows the subcommand to be accessed via *either* the original name, or this given
2252 /// particular subcommand within an [`ArgMatches`] struct, one only needs to
2260 /// .subcommand(Command::new("test")
2276 /// Add an alias, which functions as "hidden" short flag subcommand
2278 /// This will automatically dispatch as if this subcommand was used. This is more efficient,
2287 /// .subcommand(Command::new("test").short_flag('t')
2303 /// Add an alias, which functions as a "hidden" long flag subcommand.
2305 /// This will automatically dispatch as if this subcommand was used. This is more efficient,
2314 /// .subcommand(Command::new("test").long_flag("test")
2329 /// Sets multiple hidden aliases to this subcommand.
2331 /// This allows the subcommand to be accessed via *either* the original name or any of the
2340 /// particular subcommand within an [`ArgMatches`] struct, one only needs to
2348 /// .subcommand(Command::new("test")
2366 /// These will automatically dispatch as if this subcommand was used. This is more efficient,
2375 /// .subcommand(Command::new("test").short_flag('t')
2394 /// These will automatically dispatch as if this subcommand was used. This is more efficient,
2403 /// .subcommand(Command::new("test").long_flag("test")
2419 /// Sets a visible alias to this subcommand.
2421 /// This allows the subcommand to be accessed via *either* the
2427 /// message and displayed as if it were just another regular subcommand. If
2432 /// particular subcommand within an [`ArgMatches`] struct, one only needs to
2440 /// .subcommand(Command::new("test")
2456 /// Add an alias, which functions as "visible" short flag subcommand
2458 /// This will automatically dispatch as if this subcommand was used. This is more efficient,
2469 /// .subcommand(Command::new("test").short_flag('t')
2486 /// Add an alias, which functions as a "visible" long flag subcommand.
2488 /// This will automatically dispatch as if this subcommand was used. This is more efficient,
2499 /// .subcommand(Command::new("test").long_flag("test")
2515 /// Sets multiple visible aliases to this subcommand.
2517 /// This allows the subcommand to be accessed via *either* the
2523 /// message and displayed as if it were just another regular subcommand. If
2528 /// particular subcommand within an [`ArgMatches`] struct, one only needs to
2536 /// .subcommand(Command::new("test")
2558 /// .subcommand(Command::new("test").short_flag('b')
2582 /// .subcommand(Command::new("test").long_flag("test")
2599 /// Set the placement of this subcommand within the help.
2615 /// .subcommand(Command::new("alpha") // typically subcommands are grouped
2621 /// .subcommand(Command::new("beta")
2622 /// .display_order(1) // In order to force this subcommand to appear *first*
2654 /// Specifies that this [`subcommand`] should be hidden from help messages
2661 /// .subcommand(
2667 /// [`subcommand`]: crate::Command::subcommand()
2677 /// If no [`subcommand`] is present at runtime, error and exit gracefully.
2685 /// .subcommand(Command::new("test"))
2694 /// [`subcommand`]: crate::Command::subcommand()
2703 /// Assume unexpected positional arguments are a [`subcommand`].
2708 /// as a truly unexpected argument (i.e. one that is *NOT* an external subcommand)
2709 /// will **not** cause an error and instead be treated as a potential subcommand.
2712 /// **NOTE:** A built-in subcommand will be parsed as an external subcommand when escaped with
2720 /// // Assume there is an external subcommand named "subcmd"
2727 /// // All trailing arguments will be stored under the subcommand's sub-matches using an empty
2729 /// match m.subcommand() {
2739 /// [`subcommand`]: crate::Command::subcommand()
2750 /// Specifies how to parse external subcommand arguments.
2764 /// // Assume there is an external subcommand named "subcmd"
2771 /// // All trailing arguments will be stored under the subcommand's sub-matches using an empty
2773 /// match m.subcommand() {
2786 /// // Assume there is an external subcommand named "subcmd"
2793 /// // All trailing arguments will be stored under the subcommand's sub-matches using an empty
2795 /// match m.subcommand() {
2805 /// [`subcommands`]: crate::Command::subcommand()
2820 /// only follow the *final* subcommand. For instance using this setting
2835 /// [`subcommands`]: crate::Command::subcommand()
2846 /// By default, if an option taking multiple values is followed by a subcommand, the
2847 /// subcommand will be parsed as another value.
2850 /// cmd --foo val1 val2 subcommand
2855 /// This setting instructs the parser to stop when encountering a subcommand instead of
2859 /// cmd --foo val1 val2 subcommand
2861 /// values subcommand
2868 /// let cmd = Command::new("cmd").subcommand(Command::new("sub")).arg(
2905 /// For example, if you had a subcommand or top level application with a required argument
2906 /// that is only required as long as there is no subcommand present,
2908 /// and yet receive no error so long as the user uses a valid subcommand instead.
2910 /// **NOTE:** This defaults to false (using subcommand does *not* negate requirements)
2921 /// .subcommand(Command::new("test"))
2931 /// valid subcommand is used.
2938 /// .subcommand(Command::new("test"))
2947 /// [`subcommands`]: crate::Command::subcommand()
2975 /// When the subcommand is not present, there are several strategies you may employ, depending
2982 /// - Disable `multicall` and re-parse it with a specific subcommand
2984 /// When detecting the error condition, the [`ErrorKind`] isn't sufficient as a sub-subcommand
3009 /// and may be the same as the name of a subcommand.
3015 /// This does not allow the subcommand to be passed as the first non-path argument.
3021 /// .subcommand(Command::new("hostname"))
3022 /// .subcommand(Command::new("dnsdomainname"));
3040 /// To make an applet usable as both a multicall link and a subcommand
3051 /// .subcommand(
3062 /// assert_eq!(m.subcommand().unwrap().1.subcommand_name(), Some("true"));
3091 /// .subcommand(Command::new("sub1"))
3104 /// help Print this message or the help of the given subcommand(s)
3117 /// .subcommand(Command::new("sub1"))
3131 /// help Print this message or the help of the given subcommand(s)
3155 /// .subcommand(Command::new("sub1"))
3168 /// help Print this message or the help of the given subcommand(s)
3181 /// .subcommand(Command::new("sub1"))
3195 /// help Print this message or the help of the given subcommand(s)
3264 /// Get the short flag of the subcommand.
3270 /// Get the long flag of the subcommand.
3300 /// Iterate through the *visible* aliases for this subcommand.
3309 /// Iterate through the *visible* short aliases for this subcommand.
3318 /// Iterate through the *visible* long aliases for this subcommand.
3327 /// Iterate through the set of *all* the aliases for this subcommand, both visible and hidden.
3333 /// Iterate through the set of *all* the short aliases for this subcommand, both visible and hidden.
3339 /// Iterate through the set of *all* the long aliases for this subcommand, both visible and hidden.
3394 /// Returns the subcommand value name.
3424 /// Find subcommand such that its name or one of aliases equals `name`.
3433 /// Find subcommand such that its name or one of aliases equals `name`, returning
3434 /// a mutable reference to the subcommand.
3689 /// Configured parser for values passed to an external subcommand
3774 if let Some((id, matches)) = matches.subcommand() {
3789 // before parsing in case we run into a subcommand
3945 // Display subcommand name, short and long in usage
4042 // Display subcommand name, short and long in usage
4268 debug!("Command::_check_help_and_version: Building help subcommand");
4269 let help_about = "Print this message or the help of the given subcommand(s)";
4272 // Slow code path to recursively clone all other subcommand subtrees under help
4285 help_subcmd.subcommand(help_help_subcmd)
4288 Arg::new("subcommand")
4292 .help("Print help for the subcommand(s)"),
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.
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.
4542 /// Find a flag subcommand name by short flag or an alias
4549 /// Find a flag subcommand name by long flag or an alias