aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 7de513a..d2dc7e9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -57,10 +57,14 @@ Usage: t [-t DIR] [-l LIST] [options] [TEXT]";
.opt_str("t")
.unwrap_or_else(|| path.to_str().unwrap().to_string());
+ if !Path::new(&taskdir).exists() {
+ eprintln!("Directory does not exist: {}", taskdir);
+ return;
+ }
+ // read files
let mut taskpath = PathBuf::from(&taskdir);
taskpath.push(&taskfile);
- // read files
let mut donepath = taskpath.as_path().parent().unwrap().to_path_buf();
donepath.push(donefile);
@@ -94,6 +98,13 @@ Usage: t [-t DIR] [-l LIST] [options] [TEXT]";
write_files(tasks, done, taskpath, donepath, delete_empty);
return;
}
+ // remove task
+ if matches.opt_present("r") {
+ let task = matches.opt_str("f").unwrap();
+ tasks.remove(&task);
+ write_files(tasks, done, taskpath, donepath, delete_empty);
+ return;
+ }
// add new task
if !matches.free.is_empty() {