[][src]Function go_flag::parse_args_with_warnings

pub fn parse_args_with_warnings<'a, T, S: AsRef<OsStr>, F>(
    args: &[S],
    warnings: Option<&mut Vec<FlagWarning>>,
    f: F
) -> Result<Vec<T>, FlagError> where
    T: FlagValue,
    F: FnOnce(&mut FlagSet<'a>), 

Parses the given arguments into flags, recording warnings issued.

Flags are registered in the given closure.

Returns

Returns the list of positional arguments (remaining arguments).

Positional arguments can also be parsed. You'll typically need Vec<String>, Vec<OsString> or Vec<PathBuf>.

Errors

It returns Err if the given arguments contains invalid flags.

Example

let mut warnings = Vec::new();
let mut force = false;
let mut lines = 10_i32;
let args = ["--f", "--", "foo"];
let args: Vec<String> =
    go_flag::parse_args_with_warnings(&args, Some(&mut warnings), |flags| {
        flags.add_flag("f", &mut force);
        flags.add_flag("lines", &mut lines);
    })?;
assert_eq!(force, true);
assert_eq!(lines, 10);
assert_eq!(args, vec![String::from("foo")]);
assert_eq!(warnings[0].to_string(), "short flag with double minuses: --f");