about summary refs log tree commit diff
path: root/cli/src/main.rs
blob: d140d97513c92ab983900dbb156fe7d9005b57d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::env;

use ka::{
    actions::{create, shift, update, ActionOptions},
    filesystem::FsImpl,
};

fn main() {
    let args: Vec<String> = env::args().collect();
    let command = args[1].as_str();

    let options = ActionOptions::from_path("./repo");
    //let options = ActionOptions::from_pwd().expect("Could not get current path.");

    let filesystem = FsImpl {};

    match command {
        "create" => {
            create(options, &filesystem).expect("Failed executing Create action.");
        }
        "update" => {
            update(options, &filesystem).expect("Failed executing Update action.");
        }
        "shift" => {
            let new_cursor: usize = args[2].as_str().parse().expect("Invalid cursor.");

            shift(options, &filesystem, new_cursor).expect("Failed executing Shift actions.");
        }
        _ => panic!("Unknown command: {}", command),
    }
}