diff options
author | Nora <nora.widdecke@tu-bs.de> | 2019-02-24 19:31:31 +0100 |
---|---|---|
committer | Nora <nora.widdecke@tu-bs.de> | 2019-02-24 19:31:31 +0100 |
commit | 80cbd985236b5875b4b4c0b4233b793c8b34c3c1 (patch) | |
tree | ce3d4a10aa312c4f5628f3dee81f07d565e9c186 | |
parent | 65d8add7122a538cc2b8ab15faeb0f6351d399df (diff) |
make index work
-rw-r--r-- | src/actions/index/action.rs | 15 | ||||
-rw-r--r-- | src/bin/khaleesi.rs | 3 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/actions/index/action.rs b/src/actions/index/action.rs index ddf77ee..5c9c00b 100644 --- a/src/actions/index/action.rs +++ b/src/actions/index/action.rs @@ -6,6 +6,8 @@ use std::path::{Path,PathBuf}; use std::time::SystemTime; use walkdir::DirEntry; +use structopt::clap::ArgMatches; + use crate::defaults::*; use super::indextime; use crate::utils::fileutil; @@ -13,15 +15,14 @@ use crate::utils::lock; use crate::utils::misc; use crate::KhResult; -pub fn action_index(mut args: &[&str]) -> KhResult<()> { - let reindex = !args.is_empty() && args[0] == "--reindex"; - if reindex { - args = &args[1..]; - } - let indexpath = if args.is_empty() { +pub fn action_index(args: &ArgMatches) -> KhResult<()> { + let reindex = args.is_present("reindex"); + //let reindex = !args.is_empty() && args[0] == "--reindex"; + let indexpath = if args.is_present("path") { +// args.value_of("path").unwrap() get_caldir() } else { - PathBuf::from(&args[0]) + get_caldir() }; index_dir(&indexpath, reindex) diff --git a/src/bin/khaleesi.rs b/src/bin/khaleesi.rs index dd6990d..e44a719 100644 --- a/src/bin/khaleesi.rs +++ b/src/bin/khaleesi.rs @@ -33,6 +33,9 @@ enum Command { /// Rebuild index #[structopt(short = "r", long = "reindex")] reindex: bool, + /// index path + #[structopt(parse(from_os_str))] + path: Option<PathBuf> }, } |