cinderella

[unmaintained] simple CI engine
Log | Files | Refs | README | LICENSE

commit f090e007f9c145e7230d8fa302feda9d6a9c834b
parent 9bdfe432413298a8d210838ea1c2f4c75c7c2b8e
Author: Stefan Koch <programming@stefan-koch.name>
Date:   Sun, 24 Nov 2019 22:17:21 +0100

rewrite conditional with Option access

Diffstat:
Msrc/main.rs | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -13,15 +13,16 @@ fn print_usage(program: &str, opts: Options) { fn main() { let args: Vec<String> = env::args().collect(); - if args.len() < 2 { - println!("Please provide a command"); - } else { - match args[1].as_ref() { - "run" => run(args), - "encrypt" => encrypt(), - "decrypt" => decrypt(), - _ => println!("Unknown command!"), - }; + match args.get(1) { + Some(command) => { + match command.as_ref() { + "run" => run(args), + "encrypt" => encrypt(), + "decrypt" => decrypt(), + _ => println!("Unknown command!"), + } + }, + None => println!("Please provide a command"), } }