From 290353cad376107e08c8eeed791f329af972982d Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Thu, 20 Aug 2020 20:00:32 +0700 Subject: [PATCH] Change to clap and update the app --- Cargo.toml | 2 ++ src/main.rs | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7326b09..cd612ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,5 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +structopt = "0.3.13" +clap = "2.33.3" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e7a11a9..33d3388 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,34 @@ +use clap::{Arg, App}; + fn main() { - println!("Hello, world!"); + let matches = App::new("CUBETIQ Syncer") + .version("0.1.0") + .author("Sambo Chea ") + .about("For CUBETIQ software tools") + .arg(Arg::with_name("name") + .short("n") + .long("name") + .takes_value(true) + .help("Enter your name to register the service.")) + .arg(Arg::with_name("app_id") + .short("id") + .long("app_id") + .takes_value(true) + .help("Enter your app id that register with your service.")) + .get_matches(); + + let name = matches.value_of("name"); + let app_id = matches.value_of("app_id"); + + match name { + None => println!("User is not available for use this service!"), + Some(s) => println!("Your name is: {}", s) + } + + match app_id { + None => println!("App Id is required to process the service!"), + Some(s) => { + println!("Your app id is: {}", s); + } + } }