[][src]Function go_flag::parse_with_warnings

pub fn parse_with_warnings<'a, T, F>(mode: WarningMode, f: F) -> Vec<T> where
    T: FlagValue,
    F: FnOnce(&mut FlagSet<'a>), 

Parses the command-line arguments into flags, handling warnings as specified.

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>.

Exits

It exits if:

  • the command-line arguments contain invalid flags, or
  • mode is WarningMode::Error and we have compatibility warnings.

Outputs

It prints errors and warnings to the standard error stream (stderr).

If WarningMode::Ignore is set, we'll throw warnings away.

Example

use go_flag::WarningMode;
let mut force = false;
let mut lines = 10_i32;
let args: Vec<String> =
    go_flag::parse_with_warnings(WarningMode::Error, |flags| {
        flags.add_flag("f", &mut force);
        flags.add_flag("lines", &mut lines);
    });