Make plm search use cwd if no directory is given and update doc

This commit is contained in:
Trinity Pointard
2018-12-02 20:01:48 +01:00
parent ed71d24fe9
commit 24071a6229
3 changed files with 61 additions and 6 deletions
+6 -6
View File
@@ -19,7 +19,7 @@ pub fn command<'a, 'b>() -> App<'a, 'b> {
.short("p")
.long("path")
.takes_value(true)
.required(true)
.required(false)
.help("Path to Plume's working directory"))
.arg(Arg::with_name("force")
.short("f")
@@ -31,7 +31,7 @@ pub fn command<'a, 'b>() -> App<'a, 'b> {
.short("p")
.long("path")
.takes_value(true)
.required(true)
.required(false)
.help("Path to Plume's working directory")
).about("Regenerate Plume's search index"))
.subcommand(SubCommand::with_name("unlock")
@@ -39,7 +39,7 @@ pub fn command<'a, 'b>() -> App<'a, 'b> {
.short("p")
.long("path")
.takes_value(true)
.required(true)
.required(false)
.help("Path to Plume's working directory")
).about("Release lock on search directory"))
}
@@ -55,7 +55,7 @@ pub fn run<'a>(args: &ArgMatches<'a>, conn: &Connection) {
}
fn init<'a>(args: &ArgMatches<'a>, conn: &Connection) {
let path = args.value_of("path").unwrap();
let path = args.value_of("path").unwrap_or(".");
let force = args.is_present("force");
let path = Path::new(path).join("search_index");
@@ -82,7 +82,7 @@ fn init<'a>(args: &ArgMatches<'a>, conn: &Connection) {
}
fn refill<'a>(args: &ArgMatches<'a>, conn: &Connection, searcher: Option<Searcher>) {
let path = args.value_of("path").unwrap();
let path = args.value_of("path").unwrap_or(".");
let path = Path::new(path).join("search_index");
let searcher = searcher.unwrap_or_else(|| Searcher::open(&path).unwrap());
@@ -102,7 +102,7 @@ fn refill<'a>(args: &ArgMatches<'a>, conn: &Connection, searcher: Option<Searche
fn unlock<'a>(args: &ArgMatches<'a>) {
let path = args.value_of("path").unwrap();
let path = args.value_of("path").unwrap_or(".");
let path = Path::new(path).join("search_index/.tantivy-indexer.lock");
remove_file(path).unwrap();