Skip to main content

simple/
simple.rs

1use std::env;
2
3use medusa::{CommandLine, Handler, Variant};
4
5mod functions;
6
7fn main() {
8    let mut handler: Handler = Handler::new();
9    handler.add(
10        String::from("--help"),
11        Variant::Plain(functions::show_help),
12        String::from("Show this help message."),
13    );
14    handler.add(
15        String::from("--echo"),
16        Variant::WithArg(functions::echo),
17        String::from("Print the argument passed for this option."),
18    );
19    handler.add(
20        String::from("--version"),
21        Variant::Plain(functions::get_version),
22        String::from("Print current version."),
23    );
24
25    let mut command: CommandLine = CommandLine::new();
26    command.set_handler(handler);
27    command.set_name("mycli");
28    command.set_version("v1.2.8-alpha.1");
29    command.run(env::args());
30}