2 #[cfg(feature = "yaml")]
9 /// The abstract representation of a command line subcommand.
11 /// This struct describes all the valid options of the subcommand for the program. Subcommands are
12 /// essentially "sub-[`App`]s" and contain all the same possibilities (such as their own
13 /// [arguments], subcommands, and settings).
18 /// # use clap::{App, Arg, SubCommand};
19 /// App::new("myprog")
21 /// SubCommand::with_name("config")
22 /// .about("Used for configuration")
23 /// .arg(Arg::with_name("config_file")
24 /// .help("The configuration file to use")
28 /// [`App`]: ./struct.App.html
29 /// [arguments]: ./struct.Arg.html
30 #[derive(Debug, Clone)]
31 pub struct SubCommand
<'a
> {
35 pub matches
: ArgMatches
<'a
>,
38 impl<'a
> SubCommand
<'a
> {
39 /// Creates a new instance of a subcommand requiring a name. The name will be displayed
40 /// to the user when they print version or help and usage information.
45 /// # use clap::{App, Arg, SubCommand};
46 /// App::new("myprog")
48 /// SubCommand::with_name("config"))
51 pub fn with_name
<'b
>(name
: &str) -> App
<'a
, 'b
> { App::new(name) }
53 /// Creates a new instance of a subcommand from a YAML (.yml) document
59 /// # extern crate clap;
60 /// # use clap::Subcommand;
62 /// let sc_yaml = load_yaml!("test_subcommand.yml");
63 /// let sc = SubCommand::from_yaml(sc_yaml);
66 #[cfg(feature = "yaml")]
67 pub fn from_yaml(yaml
: &Yaml
) -> App { App::from_yaml(yaml) }