Crates.io | clip |
lib.rs | clip |
version | 0.1.1 |
source | src |
created_at | 2019-08-13 18:13:03.079025 |
updated_at | 2019-08-13 18:17:16.047046 |
description | A command line parser that doesn't use std or alloc! |
homepage | |
repository | |
max_upload_size | |
id | 156523 |
size | 20,741 |
A command line parser that doesn't use std or alloc!
I mainly did this for educational purposes. I've never written a library that did not use the std
or alloc
crates, so I wanted to learn how.
I also think the portability of this crate will be useful in implementing Rusty-CI
extern crate clip;
use clip::App;
use std::env::args;
fn main() {
let strings = &args().collect::<Vec<String>>()[..];
let values: Vec<&str> = strings.iter().map(|s| &**s).collect();
let mut app = App::new(&values[1..])
.name("name")
.flag("--input", 1)
.flag("--output", 1)
.flag("--link", -1)
;
app.parse();
println!(
"name: {}\ninput: {}\noutput: {}\nlink: {:?}",
app.get("name")[0],
app.get("--input")[0],
app.get("--output")[0],
app.get("--link"),
)
}