init cli
This commit is contained in:
parent
c0dbffcf0f
commit
6f2f10dbfe
22
src/main.rs
22
src/main.rs
|
@ -3,20 +3,28 @@ fn main() {
|
||||||
let app = App::new("sclient")
|
let app = App::new("sclient")
|
||||||
.arg(Arg::with_name("pattern")
|
.arg(Arg::with_name("pattern")
|
||||||
.long("pattern")
|
.long("pattern")
|
||||||
.takes_value(true));
|
.takes_value(true)
|
||||||
|
.required(true)
|
||||||
|
)
|
||||||
|
.arg(Arg::with_name("servername")
|
||||||
|
.long("servername")
|
||||||
|
.takes_value(true)
|
||||||
|
.required(true)
|
||||||
|
)
|
||||||
|
.arg(Arg::with_name("k")
|
||||||
|
.short("k")
|
||||||
|
.takes_value(true)
|
||||||
|
.required(true)
|
||||||
|
);
|
||||||
// println!("Hello, world!");
|
// println!("Hello, world!");
|
||||||
//
|
//
|
||||||
let matches = app.get_matches();
|
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());
|
println!("{}",matches.value_of("pattern").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
// cargo run test
|
// cargo run test
|
||||||
|
// cargo build
|
||||||
|
// cargo run -- --help
|
||||||
// target/debug/sclient --help
|
// target/debug/sclient --help
|
||||||
// target/debug/sclient --pattern=kevin
|
// target/debug/sclient --pattern=kevin
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue