diff --git a/Cargo.lock b/Cargo.lock index a631494..d47a346 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -225,15 +225,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "clippable-cli" -version = "0.1.0" -dependencies = [ - "clap", - "serde", - "serde_json", -] - [[package]] name = "clippable-server" version = "0.1.0" @@ -771,9 +762,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.103" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" +checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce" [[package]] name = "lock_api" @@ -856,9 +847,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" dependencies = [ "libc", "log", @@ -1128,9 +1119,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741" [[package]] name = "proc-macro-hack" @@ -1733,7 +1724,7 @@ dependencies = [ "bytes", "libc", "memchr", - "mio 0.7.13", + "mio 0.7.14", "num_cpus", "once_cell", "pin-project-lite", diff --git a/Cargo.toml b/Cargo.toml index 0dc1f68..2b64e87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,10 +5,7 @@ edition = "2018" [workspace] -members = [ - "api", - "clippable-cli", -] +members = [ "api" ] [[bin]] name = "api" diff --git a/clippable-cli/Cargo.toml b/clippable-cli/Cargo.toml deleted file mode 100644 index bed2de7..0000000 --- a/clippable-cli/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "clippable-cli" -version = "0.1.0" -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0" } - -# For commanline parsing -clap = "2.33.3" - diff --git a/clippable-cli/src/main.rs b/clippable-cli/src/main.rs deleted file mode 100644 index 5e6fd15..0000000 --- a/clippable-cli/src/main.rs +++ /dev/null @@ -1,87 +0,0 @@ -use clap::{App, Arg, AppSettings}; -use dblib::DB; - -const DEFAULT_STORAGE: &'static str = "store.json"; - -fn main() { - let matches = App::new("clippable-cli") - .version("0.1") - .author("shockrah") - .about("CLI Tool for clippable") - .setting(AppSettings::ArgRequiredElseHelp) - .arg(Arg::with_name("generate-key") - .short("g") - .long("generate-key") - .value_name("NAME") - .help("Generates a new API key to allow usage in this server")) - .arg(Arg::with_name("remove-key") - .short("r") - .long("remove-key") - .value_name("NAME") - .help("Removes a key based on the given name")) - .arg(Arg::with_name("update-key") - .short("u") - .long("update-key") - .value_name("NAME") - .help("Generate a new key for that user identified by NAME")) - .arg(Arg::with_name("new-store") - .short("s") - .long("new-store") - .value_name("filename") - .help("Creates a new file store with the appropriatte structures")) - .get_matches(); - - if let Some(filename) = matches.value_of("new-store") { - println!("Creating new store {}", filename); - create_new_store(filename.to_string()); - } - - if let Some(name) = matches.value_of("generate-key") { - println!("Genating key for {}", name); - generate_key(String::from(name)); - } - - if let Some(name) = matches.value_of("remove-key") { - println!("Removing key for {}", name); - remove_key(String::from(name)); - } - - if let Some(name) = matches.value_of("update-key") { - println!("Updating key for {}", name); - update_key(String::from(name)); - } - - -} - -fn create_new_store(filename: String) { - match DB::new_store(filename) { - Ok(_) => println!("Store created"), - Err(e) => eprintln!("Error: {}", e) - } -} - -fn generate_key(name: String) { - match DB::new_entry(String::from(DEFAULT_STORAGE), name.clone()) { - Ok(key) => println!("Key for {}\t{}", name, key), - Err(e) => eprintln!("Error: {}", e) - } -} - -fn remove_key(name: String) { - match DB::remove_entry(String::from(DEFAULT_STORAGE), name.clone()) { - Ok(removed) => { - match removed { - true => println!("Removed key for {}", name), - false => println!("Warning: unable to remove key for {}", name) - }; - }, - Err(e) => eprintln!("Error removing key: {}", e) - } -} - -fn update_key(name: String) { - remove_key(name.clone()); - generate_key(name); -} -