cli
This commit is contained in:
parent
d8a4990203
commit
c0dbffcf0f
26
src/main.rs
26
src/main.rs
|
@ -1,16 +1,24 @@
|
||||||
|
use clap::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
let app = App::new("sclient")
|
||||||
|
.arg(Arg::with_name("pattern")
|
||||||
let pattern = std::env::args().nth(1).expect("no pattern given");
|
.long("pattern")
|
||||||
let path = std::env::args().nth(2).expect("no path given");
|
.takes_value(true));
|
||||||
let args = Cli {
|
// println!("Hello, world!");
|
||||||
pattern: pattern,
|
//
|
||||||
//path: std::path::PathBuf::from(path),
|
let matches = app.get_matches();
|
||||||
};
|
// let pattern = std::env::args().nth(1).expect("no pattern given");
|
||||||
println!("{}",args.pattern)
|
// 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
|
// cargo run test
|
||||||
|
// target/debug/sclient --help
|
||||||
|
// target/debug/sclient --pattern=kevin
|
||||||
|
|
||||||
struct Cli {
|
struct Cli {
|
||||||
pattern: String,
|
pattern: String,
|
||||||
|
|
Loading…
Reference in New Issue