Skip to main content

requests_version

Function requests_version 

Source
pub fn requests_version(args: &[OsString]) -> bool
Expand description

Detects whether the provided argv-style slice specifically requests the program version.

§Returns

true if args has exactly two elements and the second element is --version or -V, false otherwise.

§Examples

use std::ffi::OsString;

let args = vec![OsString::from("runner"), OsString::from("--version")];
assert!(runner::requests_version(&args));

let args2 = vec![OsString::from("runner"), OsString::from("-V")];
assert!(runner::requests_version(&args2));

let args3 = vec![OsString::from("runner")];
assert!(!runner::requests_version(&args3));

let args4 = vec![OsString::from("runner"), OsString::from("--version"), OsString::from("extra")];
assert!(!runner::requests_version(&args4));