使用旧的Rust 2015
0.6.1 |
|
---|---|
0.6.0 |
|
0.5.0 |
|
0.4.0 |
|
0.1.2 |
|
5 in #commands
32KB
842 行
scp
Rust的简单命令解析器。
用法
- 将
scp
添加到您的Cargo.toml
文件[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()); } } }