From 8bcbf51cf4f7924600eae39db67ff653b48ad95d Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 20 Sep 2021 17:36:40 +0200 Subject: Extract CLI --- cli/Cargo.toml | 9 +++++++++ cli/src/main.rs | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 cli/Cargo.toml create mode 100644 cli/src/main.rs (limited to 'cli') diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 0000000..a1d090c --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "ka-cli" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ka = { path = "../" } \ No newline at end of file diff --git a/cli/src/main.rs b/cli/src/main.rs new file mode 100644 index 0000000..945da3a --- /dev/null +++ b/cli/src/main.rs @@ -0,0 +1,24 @@ +use std::env; + +use ka::{create_command, shift_command, update_command}; + +fn main() { + let args: Vec = env::args().collect(); + let command = args[1].as_str(); + match command { + "create" => { + create_command().unwrap(); + } + "update" => { + update_command().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); + } + _ => println!("Unknown command: {}", command), + } +} -- cgit 1.4.1