| Crates.io | scp |
| lib.rs | scp |
| version | 0.6.1 |
| created_at | 2019-05-08 01:28:50.301304+00 |
| updated_at | 2019-11-15 20:10:08.434417+00 |
| description | A Rust library that parses strings of text as commands, subcommands, parameters and options. |
| homepage | |
| repository | https://github.com/idkp/scp |
| max_upload_size | |
| id | 132727 |
| size | 35,745 |
A Simple Command Parser for Rust.
scp to your Cargo.toml file:
[dependencies]
scp = "^0"
extern crate scp;
use scp::{CommandLine, Command, ExecResult, ParamAccessor};
fn main() {
let mut command_line = CommandLine::new();
command_line.register(Command::new("greet").set_syntax_format("s"));
match command_line.run("greet John\\ Doe") {
ExecResult::Err(e) => {
// handle
},
ExecResult::Ok{ command, subcommand, parameters, options } => {
println!("Hello, {}!", parameters.poll());
}
}
}