Skip to content

Instantly share code, notes, and snippets.

Created September 7, 2017 22:31
Show Gist options
  • Save anonymous/ac4b25c7648b097b65d8bceeb9b062e1 to your computer and use it in GitHub Desktop.
Save anonymous/ac4b25c7648b097b65d8bceeb9b062e1 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
extern crate clap;
use clap::{App,Arg};
fn main() {
let m = App::new("My Program")
.arg(
Arg::with_name("demo").short("d")
)
.arg(
Arg::with_name("rest")
.multiple(true)
.last(true)
)
.get_matches_from(&["cmd", "-d", "--", "foo", "bar"][..]);
for arg in m.values_of("rest").unwrap() {
println!("Got arg: {}", arg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment