Lines Matching defs:arg

60 ///     .arg(
148 /// # use clap::{Command, arg, Arg};
151 /// .arg(
158 /// .arg(
159 /// arg!(-c --config <CONFIG> "Optionally sets a config file to use")
165 pub fn arg(mut self, a: impl Into<Arg>) -> Self {
166 let arg = a.into();
167 self.arg_internal(arg);
171 fn arg_internal(&mut self, mut arg: Arg) {
173 if !arg.is_positional() {
175 arg.disp_ord.get_or_insert(current);
180 arg.help_heading
182 self.args.push(arg);
190 /// # use clap::{Command, arg, Arg};
193 /// arg!("[debug] -d 'turns on debugging info'"),
201 for arg in args {
202 self = self.arg(arg);
221 /// .arg(Arg::new("bar")
317 /// # use clap::{Command, arg, ArgGroup};
319 /// .arg(arg!("--set-ver [ver] 'set the version manually'"))
320 /// .arg(arg!("--major 'auto increase major'"))
321 /// .arg(arg!("--minor 'auto increase minor'"))
322 /// .arg(arg!("--patch 'auto increase patch'"))
340 /// # use clap::{Command, arg, ArgGroup};
342 /// .arg(arg!("--set-ver [ver] 'set the version manually'"))
343 /// .arg(arg!("--major 'auto increase major'"))
344 /// .arg(arg!("--minor 'auto increase minor'"))
345 /// .arg(arg!("--patch 'auto increase patch'"))
346 /// .arg(arg!("-c [FILE] 'a config file'"))
347 /// .arg(arg!("-i [IFACE] 'an interface'"))
378 /// # use clap::{Command, arg};
382 /// .arg(arg!("<config> 'Required configuration file to use'")))
411 /// .arg(Arg::new("config_file")),
440 /// .arg(
928 /// # use clap::{Command, arg};
931 /// .arg(arg!(<cmd> ... "commands to run"))
954 /// # use clap::{Command, arg};
957 /// .arg(arg!(-c --config <FILE> "Sets a custom config file"))
958 /// .arg(arg!(-x --stuff <FILE> "Sets a custom stuff file"))
959 /// .arg(arg!(f: -f "Flag"));
983 /// This is the equivalent to saying the `foo` arg using [`Arg::overrides_with("foo")`] for all
1270 /// .arg(
1283 /// .arg(
1845 /// This will be used for any arg that hasn't had [`Arg::help_heading`] called.
1852 /// [`Command::arg`]: Command::arg()
1863 /// This will be used for any arg that hasn't had [`Arg::display_order`] called.
1937 /// .arg(Arg::new("save-context")
1940 /// .arg(Arg::new("save-runtime")
1959 /// .arg(Arg::new("save-context")
1962 /// .arg(Arg::new("save-runtime")
1965 /// .arg(Arg::new("format")
2091 /// .arg(Arg::new("arg1"))
2092 /// .arg(Arg::new("arg2")
2109 /// .arg(Arg::new("arg1")
2111 /// .arg(Arg::new("arg2")
2128 /// .arg(Arg::new("foo"))
2129 /// .arg(Arg::new("bar"))
2130 /// .arg(Arg::new("baz").action(ArgAction::Set).num_args(1..))
2147 /// .arg(Arg::new("foo"))
2148 /// .arg(Arg::new("bar"))
2149 /// .arg(Arg::new("baz").action(ArgAction::Set).num_args(1..))
2182 /// Command::new("sync").short_flag('S').arg(
2219 /// Command::new("sync").long_flag("sync").arg(
2350 /// .arg(Arg::new("input")
2377 /// .arg(Arg::new("input")
2405 /// .arg(Arg::new("input")
2868 /// let cmd = Command::new("cmd").subcommand(Command::new("sub")).arg(
2869 /// Arg::new("arg")
2870 /// .long("arg")
2877 /// .try_get_matches_from(&["cmd", "--arg", "1", "2", "3", "sub"])
2880 /// matches.get_many::<String>("arg").unwrap().collect::<Vec<_>>(),
2887 /// .try_get_matches_from(&["cmd", "--arg", "1", "2", "3", "sub"])
2890 /// matches.get_many::<String>("arg").unwrap().collect::<Vec<_>>(),
2920 /// .arg(Arg::new("opt").required(true))
2937 /// .arg(Arg::new("opt").required(true))
3477 /// If the given arg contains a conflict with an argument that is unknown to
3479 pub fn get_arg_conflicts_with(&self, arg: &Arg) -> Vec<&Arg> // FIXME: This could probably have been an iterator
3481 if arg.is_global_set() {
3482 self.get_global_arg_conflicts_with(arg)
3485 for id in arg.blacklist.iter() {
3486 if let Some(arg) = self.find(id) {
3487 result.push(arg);
3495 panic!("Command::get_arg_conflicts_with: The passed arg conflicts with an arg unknown to the cmd");
3509 // If the given arg contains a conflict with an argument that is unknown to
3511 fn get_global_arg_conflicts_with(&self, arg: &Arg) -> Vec<&Arg> // FIXME: This could probably have been an iterator
3513 arg.blacklist
3519 self.get_subcommands_containing(arg)
3523 .find(|arg| arg.get_id() == id)
3526 The passed arg conflicts with an arg unknown to the cmd",
3545 fn get_subcommands_containing(&self, arg: &Arg) -> Vec<&Self> {
3551 .any(|ar| ar.get_id() == arg.get_id())
3554 vec.append(&mut self.subcommands[idx].get_subcommands_containing(arg));
3905 for arg in self.args.args_mut() {
3906 if is_allow_hyphen_values_set && arg.is_takes_value_set() {
3907 arg.settings.insert(ArgSettings::AllowHyphenValues.into());
3909 if is_allow_negative_numbers_set && arg.is_takes_value_set() {
3910 arg.settings
3913 if is_trailing_var_arg_set && arg.get_index() == Some(highest_idx) {
3914 arg.settings.insert(ArgSettings::TrailingVarArg.into());
4132 .filter(|arg| arg.get_help().is_none() && arg.get_long_help().is_none())
4133 .map(|arg| arg.get_id().clone())
4240 let mut arg = Arg::new(Id::HELP)
4245 arg = arg
4249 arg = arg.help("Print help");
4253 self.args.push(arg);
4257 let arg = Arg::new(Id::VERSION)
4264 self.args.push(arg);
4287 Command::new("help").about(help_about).arg(
4441 /// Iterate through the groups this arg is member of.
4442 pub(crate) fn groups_for_arg<'a>(&'a self, arg: &Id) -> impl Iterator<Item = Id> + 'a {
4443 debug!("Command::groups_for_arg: id={:?}", arg);
4444 let arg = arg.clone();
4447 .filter(move |grp| grp.args.iter().any(|a| a == &arg))
4499 debug!("Command::unroll_args_in_group:iter: this is an arg");
4512 pub(crate) fn unroll_arg_requires<F>(&self, func: F, arg: &Id) -> Vec<Id>
4517 let mut r_vec = vec![arg];
4527 if let Some(arg) = self.find(a) {
4528 for r in arg.requires.iter().filter_map(&func) {