Crate parse_argument
source ·Expand description
parse_arguments_rs
Easy way to deal with parsing commandline arguments
Can be used with any type that implements FromStr (for parsing).
Use parse_argument() function to find a value for a specified key (flag). Look at the examples for an idea of how to use it. 
It works for arguments that look like this: 
./rust_code --setting=foo --num=42 --hello="world"
And to retrieve those values you would write:
let _ = parse_argument::<Setting>("option").unwrap().unwrap();
let _ = parse_argument::<i32>("num").unwrap().unwrap();
let _ = parse_argument::<String>("hello").unwrap().unwrap();Run cargo doc --open to see the documentation.
TODO
- the key nor the value can have any spaces because of the nature of std::env::args. I will try to fix it at some point.
- Make a function that returns a hashmap of all the arguments with their key and value
Enums
- Errors for parse_argument(). Takes type<<T as FromStr>::Err>
Functions
- Takes an argument flag, and a type (generally with turbofish syntax). Will look for any arguments instd::env::argsthat contains--{flag}=. Then it will split it and try to parse it.