diff options
author | Nora <nora.widdecke@tu-bs.de> | 2019-02-25 00:24:26 +0100 |
---|---|---|
committer | Nora <nora.widdecke@tu-bs.de> | 2019-02-25 00:24:26 +0100 |
commit | f236acf855de423e84faf6f5cd93a596ee02863b (patch) | |
tree | 4266764b316340568174d4a3ef495dd58c46e883 | |
parent | 1f375e9dccfacc8d898d9b7f906b4e4da70580f5 (diff) |
structopt undo and unroll
-rw-r--r-- | src/actions/undo.rs | 4 | ||||
-rw-r--r-- | src/actions/unroll.rs | 6 | ||||
-rw-r--r-- | src/bin/khaleesi.rs | 8 | ||||
-rw-r--r-- | src/cli.rs | 13 |
4 files changed, 20 insertions, 11 deletions
diff --git a/src/actions/undo.rs b/src/actions/undo.rs index dbc4dbb..2fa2c83 100644 --- a/src/actions/undo.rs +++ b/src/actions/undo.rs @@ -6,7 +6,7 @@ use std::fs; use std::path::{Path, PathBuf}; use walkdir::WalkDir; -pub fn do_undo(_args: &[&str]) -> KhResult<()> { +pub fn do_undo() -> KhResult<()> { let backupdir = defaults::get_backupdir(); let source_dir = get_most_recent_backup()?; @@ -124,7 +124,7 @@ mod integration { #[test] fn test_do_undo() { let testdir = prepare_testdir("testdir_with_backup"); - do_undo(&[]).unwrap(); + do_undo().unwrap(); let target_folder = testdir.child(".khaleesi/cal/my_calendar/twodaysacrossbuckets.ics"); target_folder.assert(predicate::path::exists()); } diff --git a/src/actions/unroll.rs b/src/actions/unroll.rs index 16a9c31..044eb59 100644 --- a/src/actions/unroll.rs +++ b/src/actions/unroll.rs @@ -2,10 +2,10 @@ use std::path::Path; use crate::khline::KhLine; use crate::KhResult; +use crate::cli::Unroll; -pub fn action_unroll(args: &[&str]) -> KhResult<()> { - let file = &args[0]; - let filepath = Path::new(file); +pub fn action_unroll(args: &Unroll) -> KhResult<()> { + let filepath = &args.path; do_unroll(filepath)?; Ok(()) diff --git a/src/bin/khaleesi.rs b/src/bin/khaleesi.rs index 8b2a1ea..605c3c8 100644 --- a/src/bin/khaleesi.rs +++ b/src/bin/khaleesi.rs @@ -59,12 +59,8 @@ fn main_internal(args: &cli::CommandLine, config: &Config) -> KhResult<()> { cli::Command::Seq => seq::action_seq(), // "pretty" => prettyprint::prettyprint(), cli::Command::Show => show::do_show(), - // "undo" => undo::do_undo(args), - // "unroll" => unroll::action_unroll(args), - _ => { - //print_usage(cmd); - Ok(()) - } + cli::Command::Undo => undo::do_undo(), + cli::Command::Unroll(x) => unroll::action_unroll(&x), } } @@ -50,6 +50,12 @@ pub enum Command { /// Show the raw ical file of an event #[structopt(name = "show")] Show, + /// undo the most recent action + #[structopt(name = "undo")] + Undo, + /// Unroll a recurring event + #[structopt(name = "unroll")] + Unroll(Unroll), } #[derive(Debug, StructOpt)] @@ -99,6 +105,13 @@ pub struct Select { } #[derive(Debug, StructOpt)] +pub struct Unroll { + /// The file to unroll + #[structopt(name = "path", parse(from_os_str))] + pub path: PathBuf, +} + +#[derive(Debug, StructOpt)] pub struct New { /// the calendar #[structopt(name = "calendar")] |