about summary refs log tree commit diff
path: root/cli
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2021-09-20 22:25:55 +0200
committerMel <einebeere@gmail.com>2021-09-20 22:25:55 +0200
commitc25d22681f9bc6ddba512895182af0ce0252731b (patch)
treeeadcdec7d0b4d26d59e77169bd89b8db13e22fb6 /cli
parent8bcbf51cf4f7924600eae39db67ff653b48ad95d (diff)
downloadka-c25d22681f9bc6ddba512895182af0ce0252731b.tar.zst
ka-c25d22681f9bc6ddba512895182af0ce0252731b.zip
Split out common logic
Diffstat (limited to 'cli')
-rw-r--r--cli/src/main.rs11
1 files changed, 7 insertions, 4 deletions
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<String> = 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),
     }