Skip to content

Commit

Permalink
Add helper fn to Arg that denotes raw parsing on value
Browse files Browse the repository at this point in the history
  • Loading branch information
stevepentland committed Feb 23, 2018
1 parent 4e45a46 commit 66a78f2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/args/arg.rs
Expand Up @@ -3711,6 +3711,29 @@ impl<'a, 'b> Arg<'a, 'b> {
self
}

/// Indicates that all parameters passed after this should not be parsed
/// individually, but rather passed in their entirety. It is worth noting
/// that setting this requires all values to come after a `--` to indicate they
/// should all be captured. For example:
///
/// ```notrust
/// --foo something -- -v -v -v -b -b -b --baz -q -u -x
/// ```
/// Will result in everything after `--` to be considered one raw argument. This behavior
/// may not be exactly what you are expecting and using [`AppSettings::TrailingVarArg`]
/// may be more appropriate.
///
/// **NOTE:** Implicitly sets [`Arg::multiple(true)`], [`Arg::allow_hyphen_values(true)`], and
/// [`Arg::last(true)`] when set to `true`
///
/// [`Arg::multiple(true)`]: ./struct.Arg.html#method.multiple
/// [`Arg::allow_hyphen_values(true)`]: ./struct.Arg.html#method.allow_hyphen_values
/// [`Arg::last(true)`]: ./struct.Arg.html#method.last
/// [`AppSettings::TrailingVarArg`]: ./enum.AppSettings.html#variant.TrailingVarArg
pub fn raw(self, raw: bool) -> Self {
self.multiple(raw).allow_hyphen_values(raw).last(raw)
}

/// Checks if one of the [`ArgSettings`] settings is set for the argument
/// [`ArgSettings`]: ./enum.ArgSettings.html
pub fn is_set(&self, s: ArgSettings) -> bool { self.b.is_set(s) }
Expand Down

0 comments on commit 66a78f2

Please sign in to comment.