#command #parse #cli #parser

yanked scp

A Rust library that parses strings of text as commands, subcommands, parameters and options

Uses old Rust 2015

0.6.1 Nov 15, 2019
0.6.0 Aug 2, 2019
0.5.0 Aug 1, 2019
0.4.0 Jul 29, 2019
0.1.2 May 8, 2019

#7 in #commands

40 downloads per month

AML license

32KB
842 lines

scp

A Simple Command Parser for Rust.

Usage

  • Add scp to your Cargo.toml file:
    [dependencies]
    scp = "^0"
    
  • Start coding!
    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());
            }
        }
    }
    

No runtime deps