diff options
| author | Mel <einebeere@gmail.com> | 2021-09-20 17:36:40 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2021-09-20 17:36:40 +0200 |
| commit | 8bcbf51cf4f7924600eae39db67ff653b48ad95d (patch) | |
| tree | 6ee9ea655c1c983938d9dde63bb68dcb26342b89 /src | |
| parent | 7667695eba44f94c064708f5f4c54f78d685b024 (diff) | |
| download | ka-8bcbf51cf4f7924600eae39db67ff653b48ad95d.tar.zst ka-8bcbf51cf4f7924600eae39db67ff653b48ad95d.zip | |
Extract CLI
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs (renamed from src/main.rs) | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/src/main.rs b/src/lib.rs index fcbb4d0..3a05db5 100644 --- a/src/main.rs +++ b/src/lib.rs @@ -1,35 +1,13 @@ use difference::{Changeset, Difference}; use serde::{Deserialize, Serialize}; use std::{ - env, fs::{self, DirEntry, File, OpenOptions}, io::{self, Read, Seek, Write}, path::{Path, PathBuf}, vec, }; -fn main() { - let args: Vec<String> = 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), - } -} - -fn create_command() -> io::Result<()> { +pub fn create_command() -> io::Result<()> { let repository_directory = Path::new("./repository"); let ka_directory = repository_directory.join(".ka"); @@ -47,7 +25,7 @@ fn create_command() -> io::Result<()> { Ok(()) } -fn update_command() -> io::Result<()> { +pub fn update_command() -> io::Result<()> { let repository_directory = Path::new("./repository"); let ka_directory = repository_directory.join(".ka"); @@ -65,7 +43,7 @@ fn update_command() -> io::Result<()> { Ok(()) } -fn shift_command(path: &str, new_cursor: usize) { +pub fn shift_command(path: &str, new_cursor: usize) { let repository_directory = Path::new("./repository"); let ka_directory = repository_directory.join(".ka"); |
