Change to clap and update the app

This commit is contained in:
Sambo Chea 2020-08-20 20:00:32 +07:00
parent 1a689e7fe9
commit 290353cad3
2 changed files with 34 additions and 1 deletions

View File

@ -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"

View File

@ -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 <sombochea@cubetiqs.com>")
.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);
}
}
}