summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..a26cfc8
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,60 @@
+pub mod client;
+pub mod config;
+pub mod server;
+
+use crate::client::{download_vault, gen_privkey, gen_pubkey, ls_vaults, upload_vault};
+use crate::server::server_main;
+use clap::{Parser, Subcommand};
+
+#[derive(Parser)]
+#[command(
+ name = "kps",
+ version,
+ about = "A simple personal KeePassXC vault sync manager"
+)]
+struct CliArgs {
+ #[command(subcommand)]
+ command: Commands,
+}
+#[derive(Subcommand)]
+enum Commands {
+ #[command(
+ alias = "pubkey",
+ about = "Generates an ed25519 public key from the given private key"
+ )]
+ PublicKey,
+ #[command(alias = "privkey", about = "Generates an ed25519 private key")]
+ PrivateKey,
+ #[command(about = "Starts the kps server")]
+ Server,
+ #[command(about = "Uploads your vault to the kps server")]
+ Upload,
+ #[command(alias = "ls", about = "Lists the available vaults")]
+ Vaults {
+ #[arg(long, default_value = "false")]
+ long: bool,
+ },
+ #[command(about = "Downloads the specified vault file")]
+ Download {
+ #[arg(default_value = "latest")]
+ id: String,
+ #[arg(long, default_value = "false")]
+ install: bool,
+ #[arg(long, default_value = "vault.kdbx")]
+ file: String,
+ },
+}
+
+#[tokio::main]
+async fn main() {
+ let args = CliArgs::parse();
+
+ match args.command {
+ Commands::PublicKey => gen_pubkey(),
+ Commands::PrivateKey => gen_privkey(),
+ Commands::Server => server_main().await,
+ Commands::Upload => upload_vault(),
+ Commands::Vaults { long } => ls_vaults(long),
+ Commands::Download { id, install, file } => download_vault(id, install, file),
+ }
+}