summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora <nora.widdecke@tu-bs.de>2019-02-24 21:20:09 +0100
committerNora <nora.widdecke@tu-bs.de>2019-02-24 21:20:09 +0100
commit253c5484047fbbff46402d7e3ebede5b170eee79 (patch)
tree11ecb8709ea10897eae247e0d0802a0790d9d75e
parentd7eb5bc24ce8db4ea679654ab33726dc924b7d53 (diff)
make index work again
-rw-r--r--src/actions/index/action.rs16
-rw-r--r--src/bin/khaleesi.rs6
-rw-r--r--src/cli.rs1
3 files changed, 7 insertions, 16 deletions
diff --git a/src/actions/index/action.rs b/src/actions/index/action.rs
index 5c9c00b..df5be14 100644
--- a/src/actions/index/action.rs
+++ b/src/actions/index/action.rs
@@ -6,23 +6,19 @@ 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;
use crate::utils::lock;
use crate::utils::misc;
use crate::KhResult;
+use crate::cli::Index;
-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 {
- get_caldir()
+pub fn action_index(args: &Index) -> KhResult<()> {
+ let reindex = args.reindex;
+ let indexpath = match &args.path {
+ Some(path) => path.clone(),
+ None => get_caldir(),
};
index_dir(&indexpath, reindex)
diff --git a/src/bin/khaleesi.rs b/src/bin/khaleesi.rs
index 5ddfb89..c27fca7 100644
--- a/src/bin/khaleesi.rs
+++ b/src/bin/khaleesi.rs
@@ -48,11 +48,7 @@ fn main_internal(args: &cli::CommandLine, config: &Config) -> KhResult<()> {
// "delete" => delete::do_delete(args),
// "edit" => edit::do_edit(args),
// "get" => get::action_get(args),
- cli::Command::Index(x) => {
- println!("{:?}", x);
- //index::action_index(),
- Ok(())
- }
+ cli::Command::Index(x) => index::action_index(x),
// "list" => list::list_by_args(args),
// "modify" => modify::do_modify(args),
// "new" => new::do_new(args),
diff --git a/src/cli.rs b/src/cli.rs
index 92441bb..519988b 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -39,6 +39,5 @@ pub struct Index {
pub reindex: bool,
/// index path
#[structopt(name = "path", parse(from_os_str))]
- //TODO for some reason, this is parsed as an &str
pub path: Option<PathBuf>,
}