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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use clap::{Parser, Subcommand};
use std::path::PathBuf;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Commands related to secrets management.
    Secrets {
        #[command(subcommand)]
        cmd: SecretsCommands,
    },
    /// Commands related to user management. Note that your root key is required for this.
    Users {
        #[command(subcommand)]
        cmd: UserCommands,
    },
    /// Commands related to setting/getting the URL for your Chamber instance.
    Website {
        #[command(subcommand)]
        cmd: WebsiteCommands,
    },
    /// Log in to your Chamber instance.
    Login(LoginArgs),
    /// Commands related to generating keys for your Chamber instance.
    Keygen(KeygenArgs),
    /// Unseal your Chamber instance.
    Unseal { chamber_key: String },
    Upload(UploadArgs)
}

#[derive(Parser, Clone)]
pub struct LoginArgs {
    #[arg(long, short = 'p')]
    pub password: Option<String>,
}

#[derive(Parser, Clone)]
pub struct ListArgs {
    #[arg(long, short = 't')]
    pub tags: Option<String>,
}

#[derive(Parser, Clone)]
pub struct KeyArgs {
    #[arg(long, short = 'k')]
    pub key: Option<String>,
}
#[derive(Parser, Clone)]
pub struct KeygenArgs {
    /// Provide a root key. Randomly generated by default.
    #[arg(long, short = 'k')]
    pub key: Option<String>,
    /// Provide a known destination for your file output.
    /// Note that you need a .bin file extension.
    #[arg(long, short = 'o')]
    pub output: Option<PathBuf>,
}

#[derive(Subcommand)]
pub enum UserCommands {
    /// Create a new user
    Create,
}

#[derive(Subcommand)]
pub enum SecretsCommands {
    /// Decrypt and view a secret stored in your Boulder instance
    Get(KeyArgs),
    /// Create a new secret
    Set { key: String, value: String },
    /// Update a secret
    Update {
        key: String,
        #[arg(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
        tags: Vec<String>,
    },
    /// List the names of all secrets currently stored (that you have access to)
    List(ListArgs),
    /// Delete a secret
    Rm(KeyArgs),
}

#[derive(Subcommand)]
pub enum WebsiteCommands {
    /// Get the current URL
    Get,
    /// Set the current URL
    Set { value: String },
}

#[derive(Parser, Clone)]
pub struct UploadArgs {
    #[arg(long, short)]
    pub key: Option<String>
}