From c55bf8866e0e0eaadad4e362bade7e58e93c0dd3 Mon Sep 17 00:00:00 2001 From: Coin de Gamma Date: Tue, 3 Sep 2024 09:29:28 +0000 Subject: [PATCH 1/2] rust project init --- Cargo.toml | 8 ++++++++ src/main.rs | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..94a0fc0 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "mps" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} From 1551b6987da5ea5e248cf9072641357c40b2dff7 Mon Sep 17 00:00:00 2001 From: Coin de Gamma Date: Tue, 3 Sep 2024 12:49:03 +0000 Subject: [PATCH 2/2] basic commands inittilization --- .gitignore | 2 ++ Cargo.toml | 1 + src/main.rs | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3ca43ae..8468d5a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb +# All vim swap files of vim +*.sw? diff --git a/Cargo.toml b/Cargo.toml index 94a0fc0..5ace58e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = { version = "4.5.16", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs index e7a11a9..36a7278 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,37 @@ +use clap::{Parser, Subcommand}; + +#[derive(Parser)] +#[command(name = "mps", version = "0.0.1", about = "MyPasswordStorage: Tool for storing your passwords locally with synchronization with git.")] +struct Cli { + #[command(subcommand)] + command: Option, +} + +#[derive(Subcommand)] +enum Commands { + + /// Initialisation of storage and config, use this in first time of usage of mps + Init, + + /// Adds new item with unique id to the db + Add { + #[arg(value_name="item_id")] + input: String + } + +} + fn main() { - println!("Hello, world!"); + let cli = Cli::parse(); + match &cli.command { + Some(Commands::Init) => { + println!("Initializing storage and config."); + } + Some(Commands::Add{input}) => { + println!("about to add new item"); + } + None => { + println!("Will be here init or list if storage inited"); + } + } }