ecla 1.0.0

Easily build command line apps
Documentation

#[macro_use]
extern crate elog;
extern crate ecla;

use ecla::App;


const HELP: &'static str = "
ecla, easily build command line apps.

Usage:
    ecla command
    ecla flag
    ecla value

Commands:
    command             Test sub command.
    flag                Test flag parsing.
    value               Test sub command value parsing.

Command Options:
    flag
        -f, --force     force to run flag command.
        -a, --all       run flag command for all files.

Options:
    --help              Show help.
    --version           Show version.
";

const VERSION: &'static str = "0.1.0";


fn main() {
    let app = App::new(HELP, VERSION);

    if let Some(_) = app.get_command("command") {
        command();
    } else if let Some(command) = app.get_command("flag") {
        let flag = command.get_flag(&["-f", "--force"]);
        if flag.is_some() {
            command_with_flag(flag.unwrap().get_value());
        } else {
            command_with_no_flag();
        }
    } else if let Some(command) = app.get_command("value") {
        command_with_value(command.get_value());
    } else {
        app.show_unknown_or_help();
    }
}

fn command() {
    infos!("Wow! You have run command!");
}

fn command_with_flag(_: Option<String>) {
    infos!("Wow! You have run command with flag!");
}

fn command_with_no_flag() {
    errors!("Oops! You have run command with no flag!");
}

fn command_with_value(value: Option<String>) {
    infos!("Wow! You have run command with value: {:?}", value);
}