surd 0.1.0

Simple and minimal command line argument parser for Rust.
Documentation
  • Coverage
  • 4.55%
    1 out of 22 items documented0 out of 0 items with examples
  • Size
  • Source code size: 15.61 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.92 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • aiocat

Surd

Simple and minimal command line argument parser for Rust.

Links

Example Code

extern crate surd;

fn main() {
    // Create a new surd app.
    let mut app = surd::Surd::new("test", "a test app", "aiocat", "1.0.0");
    app.add_flag("t", "a test flag", Vec::new());
    app.set_handler(run_main);

    // Create a sub-command for main app.
    let mut test_command = surd::SubCommand::new("test", "a test command");
    test_command.add_usage("test test");
    test_command.add_flag("at", "another test flag", vec!["atest".to_string()]);
    test_command.add_alias("t".to_string());
    test_command.set_handler(run_test);

    app.add_command(test_command);

    // Handle the command.
    app.start();
}

fn run_main(found_flags: &Vec<surd::Flag>, found_args: Vec<String>) {
    println!("main: {:?}", found_args);

    for i in found_flags.iter() {
        println!("{} - {}", i.description, i.value);
    }
}

fn run_test(found_flags: &Vec<surd::Flag>, found_args: Vec<String>) {
    println!("test: {:?}", found_args);

    for i in found_flags.iter() {
        println!("{} - {}", i.description, i.value);
    }
}

Found a Bug / Error?

If you found a bug or an error, please create a new issue at gitlab repository.

Contributing

If you want to contribute this project:

  • Make sure you add the comments for your codes.
  • Please do not something useless.

Authors

License

This project is distributed under MIT license.

Project status

Under development.