From c018247c560350de59b3dd59e4e36bab53456aff Mon Sep 17 00:00:00 2001 From: anastasia Date: Fri, 26 Mar 2021 18:18:34 +0300 Subject: [PATCH] [issue #7] CLI first commit --- src/bin/zenith-cli.rs | 101 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/bin/zenith-cli.rs diff --git a/src/bin/zenith-cli.rs b/src/bin/zenith-cli.rs new file mode 100644 index 0000000000..f5bcb2e5cc --- /dev/null +++ b/src/bin/zenith-cli.rs @@ -0,0 +1,101 @@ + +use clap::{App, AppSettings, Arg}; + +fn main() { + + let matches = App::new("zenith") + .about("Zenith CLI") + .version("1.0") + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommand( + App::new("pg") + .about("compute node postgres") + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommand( + App::new("list") + ) + .subcommand( + App::new("create") + .arg(Arg::with_name("pgdata").required(true)), + ) + .subcommand( + App::new("destroy") + ) + .subcommand( + App::new("start") + ) + .subcommand( + App::new("stop") + ) + .subcommand( + App::new("show") + ), + ) + .subcommand( + App::new("storage") + .about("storage node postgres") + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommand( + App::new("list") + ) + .subcommand( + App::new("attach") + ) + .subcommand( + App::new("detach") + ) + .subcommand( + App::new("show") + ), + ) + .get_matches(); + + + if let Some(subcommand) = matches.subcommand_name() { + println!("'git {}' was used", subcommand); + } + + match matches.subcommand() { + ("pg", Some(pg_matches)) => { + println!("pg subcommand"); + match pg_matches.subcommand() + { + ("list", _) => { + println!("list subcommand"); + } + ("create", _) => { + } + ("destroy", _) => { + } + ("start", _) => { + } + ("stop", _) => { + } + ("show", _) => { + } + ("", None) => println!("No subcommand"), + _ => unreachable!(), + } + } + ("storage", Some(storage_matches)) => { + println!("storage subcommand"); + match storage_matches.subcommand() + { + ("list", _) => { + println!("list subcommand"); + } + ("attach", _) => { + } + ("detach", _) => { + } + ("show", _) => { + } + ("", None) => println!("No subcommand"), + _ => unreachable!(), + } + } + + ("", None) => println!("No subcommand"), + _ => unreachable!(), + } +}