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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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),
}
}
|