summaryrefslogtreecommitdiff
path: root/vegilctl/src/main.rs
blob: cbfc2f23137ec4f5489c5a0f277a3089822e2c9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#[derive(Debug)]
enum Command {
    Status,
    Stop,
    Start,
    Enable,
    Disable,
}
struct CliArgs {
    command: Command,
    target: String
}
fn main() {
    let command:Command = match std::env::args().nth(1).as_deref(){
         Some("status") => Command::Status,
         Some("start") => Command::Start,
         Some("stop") => Command::Stop,
         Some("enable") => Command::Enable,
         Some("disable") => Command::Disable,
         Some(cmd) => {
             eprintln!("invalid command arg:{}", cmd);
             std::process::exit(1);
         }
         None => {
             eprintln!("Invalid input: No command arg specified\nRun with --help to get help");
             std::process::exit(1);
         }
    };
    let target = std::env::args().nth(2).expect("no target arg specified");

    let args = CliArgs {
        command,
        target
    };

    println!("command: {:?}, target: {:?}", args.command, args.target);
}