SQLite-backed Key / Value Store
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: simplified the cli arguments

+35 -42
+23 -30
src/cli.rs
··· 16 16 #[derive(Subcommand, Debug)] 17 17 pub enum Commands { 18 18 /// Add a value to the store with the given key 19 - Add { key: String, value: String }, 19 + Add { 20 + /// Key for the value 21 + key: String, 22 + 23 + /// Value to add 24 + value: String, 25 + }, 20 26 21 27 /// Get values from the store 22 - Get(GetArgs), 28 + Get { 29 + /// Keys for values to retrieve from the store 30 + keys: Vec<String>, 31 + }, 23 32 24 33 /// Remove values from the store 25 - Rm(RemoveArgs), 34 + Rm { 35 + /// Keys for values to remove from the store 36 + keys: Vec<String>, 37 + }, 26 38 27 39 /// Output the alias command for key / value pairs 28 - Alias(SetArgs), 40 + Alias { 41 + /// Keys to alias the values 42 + keys: Vec<String>, 43 + }, 29 44 30 45 /// Output the export command for a key / value pairs 31 - Export(SetArgs), 46 + Export { 47 + /// Keys to export the values 48 + keys: Vec<String>, 49 + }, 32 50 33 51 /// List all values in the store 34 52 List, ··· 39 57 /// Purges the .safirstore directory, removing it and its contents 40 58 Purge, 41 59 } 42 - 43 - /// Arguments for retrieving values from the store with the given keys 44 - #[derive(Args, Debug)] 45 - pub struct GetArgs { 46 - /// Keys to retrieve the values for 47 - /// 48 - /// Returns nothing if the key does not exist 49 - pub keys: Vec<String>, 50 - } 51 - 52 - /// Arguments for removing values from the store with given keys 53 - #[derive(Args, Debug)] 54 - pub struct RemoveArgs { 55 - /// Name of the keys to remove from the store 56 - /// 57 - /// Does nothing if the keys do not exist 58 - pub keys: Vec<String>, 59 - } 60 - 61 - /// Arguments for outputting commands with a given prefix 62 - #[derive(Args, Debug)] 63 - pub struct SetArgs { 64 - /// Name of the keys to display (e.g. alias / export) 65 - pub keys: Vec<String>, 66 - }
+12 -12
src/main.rs
··· 13 13 14 14 match &cli.command { 15 15 Commands::Add { key, value } => { 16 - safir.add(key.to_owned(), value.to_owned()); 16 + // safir.add(key.to_owned(), value.to_owned()); 17 17 } 18 - Commands::Get(args) => { 19 - safir.get(args.keys.to_owned()); 18 + Commands::Get { keys } => { 19 + // safir.get(args.keys.to_owned()); 20 20 } 21 - Commands::Rm(args) => { 22 - safir.remove(args.keys.to_owned()); 21 + Commands::Rm { keys } => { 22 + // safir.remove(args.keys.to_owned()); 23 23 } 24 - Commands::Alias(args) => { 25 - safir.custom_display("alias", args.keys.to_owned()); 24 + Commands::Alias { keys } => { 25 + // safir.custom_display("alias", args.keys.to_owned()); 26 26 } 27 - Commands::Export(args) => { 28 - safir.custom_display("export", args.keys.to_owned()); 27 + Commands::Export { keys } => { 28 + // safir.custom_display("export", args.keys.to_owned()); 29 29 } 30 30 Commands::List => { 31 - safir.list(); 31 + // safir.list(); 32 32 } 33 33 Commands::Clear => { 34 - safir.clear(); 34 + // safir.clear(); 35 35 } 36 36 Commands::Purge => { 37 - safir.purge(); 37 + // safir.purge(); 38 38 } 39 39 } 40 40