Ignore case and allowing the user to specify a path
Also ran rustfmt over the code.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
extern crate clap;
|
||||
use clap::{Arg, App};
|
||||
use clap::{App, Arg};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
pub pattern: String,
|
||||
pub ignore_case: bool
|
||||
pub ignore_case: bool,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -12,19 +13,29 @@ impl Config {
|
||||
let matches = App::new("Rack")
|
||||
.version("0.1")
|
||||
.about("Like Ack but in Rust")
|
||||
.arg(Arg::with_name("ignore case")
|
||||
.short("i")
|
||||
.help("Ignore case when looking for matches"))
|
||||
.arg(Arg::with_name("pattern")
|
||||
.help("The pattern you're looking for")
|
||||
.index(1)
|
||||
.required(true))
|
||||
.arg(
|
||||
Arg::with_name("ignore case")
|
||||
.short("i")
|
||||
.help("Ignore case when looking for matches"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("pattern")
|
||||
.help("The pattern you're looking for")
|
||||
.index(1)
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("path")
|
||||
.help("Path to search in")
|
||||
.index(2)
|
||||
.default_value("."),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
Config {
|
||||
pattern: String::from(matches.value_of("pattern").unwrap()),
|
||||
ignore_case: matches.is_present("ignore case")
|
||||
ignore_case: matches.is_present("ignore case"),
|
||||
path: String::from(matches.value_of("path").unwrap()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user