This commit is contained in:
Mr. Funk 2019-05-09 21:14:19 -04:00
parent e033d5668f
commit 554971b0f4
2 changed files with 18 additions and 9 deletions

View File

@ -5,3 +5,4 @@ authors = ["lastlink <theefunk@gmail.com>"]
edition = "2018"
[dependencies]
clap = "*"

View File

@ -1,16 +1,24 @@
use clap::*;
fn main() {
println!("Hello, world!");
let pattern = std::env::args().nth(1).expect("no pattern given");
let path = std::env::args().nth(2).expect("no path given");
let args = Cli {
pattern: pattern,
//path: std::path::PathBuf::from(path),
};
println!("{}",args.pattern)
let app = App::new("sclient")
.arg(Arg::with_name("pattern")
.long("pattern")
.takes_value(true));
// println!("Hello, world!");
//
let matches = app.get_matches();
// let pattern = std::env::args().nth(1).expect("no pattern given");
// let path = std::env::args().nth(2).expect("no path given");
// let args = Cli {
// pattern: pattern,
// //path: std::path::PathBuf::from(path),
// };
println!("{}",matches.value_of("pattern").unwrap());
}
// cargo run test
// target/debug/sclient --help
// target/debug/sclient --pattern=kevin
struct Cli {
pattern: String,