From c25d22681f9bc6ddba512895182af0ce0252731b Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 20 Sep 2021 22:25:55 +0200 Subject: Split out common logic --- cli/src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cli/src') diff --git a/cli/src/main.rs b/cli/src/main.rs index 945da3a..3105f9a 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,23 +1,26 @@ use std::env; -use ka::{create_command, shift_command, update_command}; +use ka::actions::{create, shift, update, ActionOptions}; fn main() { let args: Vec = env::args().collect(); let command = args[1].as_str(); + + let options = ActionOptions::from_pwd().expect("Could not get current path."); + match command { "create" => { - create_command().unwrap(); + create(options).unwrap(); } "update" => { - update_command().unwrap(); + update(options).unwrap(); } "shift" => { let file_path = args[2].as_str(); let new_cursor: usize = args[3].as_str().parse().expect("Invalid cursor."); - shift_command(file_path, new_cursor); + shift(options, file_path, new_cursor).unwrap(); } _ => println!("Unknown command: {}", command), } -- cgit 1.4.1