diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-10-28 19:17:13 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-10-28 19:17:13 +0200 |
commit | e33685f77b5de5dd1d45a09d6e15c50c1afe7a94 (patch) | |
tree | 2ec23ae10464c2e16e19e8cbd73325a12f931d36 /src/main.rs | |
parent | aa51e17f0252da3760bdf7b3e883a1955f9ce8dd (diff) | |
download | icktool-rs-e33685f77b5de5dd1d45a09d6e15c50c1afe7a94.tar.gz |
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index ccae56f..eb71ec6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,20 +10,31 @@ fn main() { println!("api: {}", api); } - if let Some(_) = matches.subcommand_matches("version") { - version(); - } else if let Some(_) = matches.subcommand_matches("status") { - status(); - } else { - eprintln!("no action taken!"); - std::process::exit(1); - } + let code = match matches.subcommand_name() { + Some("version") => version(), + Some("status") => status(), + None => none(), + _ => unknown(), + }; + std::process::exit(code); +} + +fn none() -> i32 { + eprintln!("No subcommand was given"); + 1 +} + +fn unknown() -> i32 { + eprintln!("Unknown command"); + 1 } -fn version() { - println!("status requested"); +fn version() -> i32 { + println!("status requested"); + 0 } -fn status() { - println!("status requested"); +fn status() -> i32 { + println!("status requested"); + 0 } |