2 unstable releases

0.2.0 Jun 18, 2019
0.1.0 Jun 15, 2019

#62 in #cli-parser

Download history 65/week @ 2024-02-26 94/week @ 2024-03-04 25/week @ 2024-03-11 44/week @ 2024-03-18 36/week @ 2024-03-25 103/week @ 2024-04-01 53/week @ 2024-04-08 31/week @ 2024-04-15 37/week @ 2024-04-22 23/week @ 2024-04-29 9/week @ 2024-05-06 31/week @ 2024-05-13 30/week @ 2024-05-20 34/week @ 2024-05-27 46/week @ 2024-06-03 35/week @ 2024-06-10

148 downloads per month

MIT/Apache

20KB
392 lines

windows-args Appveyor Crates.io Docs

A command-line argument parser for Windows, copied almost wholesale from the rust standard library.

[dependencies]
windows-args = "0.2"
use windows_args::Args;

// for a complete command line, with executable
for arg in Args::parse_cmd(r#"foobar.exe to "C:\Program Files\Hi.txt" now"#) {
    println!("{}", arg);
}

// for just args, without an executable
for arg in Args::parse_args(r#"to "C:\Program Files\Hi.txt" now"#) {
    println!("{}", arg);
}

lib.rs:

windows-args

A command-line argument parser for Windows, copied almost wholesale from the rust standard library.

Offerings include:

  • Args and ArgsOs, iterators that produce String and OsString values respectively.
  • Two parsing functions, Args::parse_cmd and Args::parse_args.
    • These differ in how they parse the first argument, and in how they treat empty input.

Due to limitations of the current implementation, this crate currently can only be used on Windows.

use windows_args::Args;

// to parse a complete command (beginning with an executable name)
let mut args = Args::parse_cmd(r#"foobar.exe to "C:\Program Files\Hi.txt" now"#);

// to parse arguments to a command (NOT beginning with an executable name)
let mut args = Args::parse_args(r#"foobar to "C:\Program Files\Hi.txt" now"#);

assert_eq!(args.next(), Some("foobar".to_string()));
assert_eq!(args.next(), Some("to".to_string()));
assert_eq!(args.next(), Some("C:\\Program Files\\Hi.txt".to_string()));
assert_eq!(args.next(), Some("now".to_string()));
assert_eq!(args.next(), None);

Dependencies

~46KB