1use clap::{Parser, Subcommand};
2use std::path::PathBuf;
3
4#[derive(Parser)]
5#[command(author, version, about, long_about = None)]
6pub struct Cli {
7 #[command(subcommand)]
8 pub command: Commands,
9}
10
11#[derive(Subcommand)]
12pub enum Commands {
13 Secrets {
15 #[command(subcommand)]
16 cmd: SecretsCommands,
17 },
18 Users {
20 #[command(subcommand)]
21 cmd: UserCommands,
22 },
23 Website {
25 #[command(subcommand)]
26 cmd: WebsiteCommands,
27 },
28 Login(LoginArgs),
30 Keygen(KeygenArgs),
32 Unseal {
34 chamber_key: String,
35 },
36 Upload(UploadArgs),
37}
38
39#[derive(Parser, Clone)]
40pub struct LoginArgs {
41 #[arg(long, short = 'u')]
42 pub username: Option<String>,
43 #[arg(long, short = 'p')]
44 pub password: Option<String>,
45}
46
47#[derive(Parser, Clone)]
48pub struct UserArgs {
49 #[arg(long, short = 'u')]
50 pub username: Option<String>,
51}
52#[derive(Parser, Clone)]
53pub struct ListArgs {
54 #[arg(long, short = 't')]
55 pub tags: Option<String>,
56}
57
58#[derive(Parser, Clone)]
59pub struct KeyArgs {
60 #[arg(long, short = 'k')]
61 pub key: Option<String>,
62}
63#[derive(Parser, Clone)]
64pub struct KeygenArgs {
65 #[arg(long, short = 'k')]
67 pub key: Option<String>,
68 #[arg(long, short = 'o')]
71 pub output: Option<PathBuf>,
72}
73
74#[derive(Parser, Clone)]
75pub struct UpdateUserArgs {
76 pub username: String,
77 pub access_level: Option<i32>,
78 #[arg(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
79 pub roles: Option<Vec<String>>
80}
81
82#[derive(Subcommand)]
83pub enum UserCommands {
84 Create(LoginArgs),
86 Update(UpdateUserArgs),
88 Delete(UserArgs),
90}
91
92#[derive(Subcommand)]
93pub enum SecretsCommands {
94 Get(KeyArgs),
96 Set { key: String, value: String },
98 Update {
100 key: String,
101 #[arg(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
102 tags: Vec<String>,
103 },
104 List(ListArgs),
106 Rm(KeyArgs),
108}
109
110#[derive(Subcommand)]
111pub enum WebsiteCommands {
112 Get,
114 Set(SetArgs),
116}
117
118#[derive(Parser, Clone)]
119pub struct SetArgs {
120 #[arg(long, short = 'v')]
121 pub value: Option<String>
122}
123
124#[derive(Parser, Clone)]
125pub struct UploadArgs {
126 #[arg(long, short)]
127 pub key: Option<String>,
128}