9 stable releases

2.0.4 Jun 4, 2020
2.0.2 Jul 21, 2019
2.0.1 Sep 3, 2018
1.1.1 Sep 3, 2018
0.1.0 Nov 17, 2017

#3 in Windows APIs

Download history 5862/week @ 2020-11-06 4056/week @ 2020-11-13 5096/week @ 2020-11-20 4045/week @ 2020-11-27 3792/week @ 2020-12-04 4498/week @ 2020-12-11 3859/week @ 2020-12-18 3575/week @ 2020-12-25 8094/week @ 2021-01-01 6452/week @ 2021-01-08 4117/week @ 2021-01-15 3271/week @ 2021-01-22 3572/week @ 2021-01-29 4478/week @ 2021-02-05 5083/week @ 2021-02-12 4348/week @ 2021-02-19

18,834 downloads per month
Used in 112 crates (10 directly)

Apache-2.0 OR MIT

22KB
408 lines

Wild::args for Rust

Allows Rust applications support wildcard arguments (*foo*, file.???, *.log.[0-9], etc.) on command-line, uniformly on all platforms, including Windows.

Unix shells automatically interpret wildcard arguments and pass them expanded (already converted to file names) to applications, but Windows' cmd.exe doesn't do that. For consistent cross-platform behavior, this crate emulates Unix-like expansion on Windows. You only need to use wild::args() instead of std::env::args().

It is more robust than using glob() on values from std::env::args(), because this crate is aware of argument quoting, and special characteres in quotes ("*") are intentionally not expanded.

The glob syntax on Windows is limited to *, ?, and [a-z]/[!a-z] ranges, as supported by the glob crate. Parsing of quoted arguments precisely follows Windows' native syntax (CommandLineToArgvW, specifically).

Usage

wild::args() is a drop-in replacement for std::env::args().

extern crate wild;

fn main() {
    let args = wild::args();
    println!("The args are: {:?}", args.collect::<Vec<_>>());
}

Usage with Clap

let matches = clap::App::new("your_app")
    .arg()
    .arg()
    .arg()
    // .get_matches(); change to:
    .get_matches_from(wild::args());

Dependencies

~13KB