chamber_cli/
args.rs

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    /// Commands related to secrets management.
14    Secrets {
15        #[command(subcommand)]
16        cmd: SecretsCommands,
17    },
18    /// Commands related to user management. Note that your root key is required for this.
19    Users {
20        #[command(subcommand)]
21        cmd: UserCommands,
22    },
23    /// Commands related to setting/getting the URL for your Chamber instance.
24    Website {
25        #[command(subcommand)]
26        cmd: WebsiteCommands,
27    },
28    /// Log in to your Chamber instance.
29    Login(LoginArgs),
30    /// Commands related to generating keys for your Chamber instance.
31    Keygen(KeygenArgs),
32    /// Unseal your Chamber instance.
33    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    /// Provide a root key. Randomly generated by default.
66    #[arg(long, short = 'k')]
67    pub key: Option<String>,
68    /// Provide a known destination for your file output.
69    /// Note that you need a .bin file extension.
70    #[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 a new user
85    Create(LoginArgs),
86    /// Create a new user
87    Update(UpdateUserArgs),
88    /// Create a new user
89    Delete(UserArgs),
90}
91
92#[derive(Subcommand)]
93pub enum SecretsCommands {
94    /// Decrypt and view a secret stored in your Boulder instance
95    Get(KeyArgs),
96    /// Create a new secret
97    Set { key: String, value: String },
98    /// Update a secret
99    Update {
100        key: String,
101        #[arg(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
102        tags: Vec<String>,
103    },
104    /// List the names of all secrets currently stored (that you have access to)
105    List(ListArgs),
106    /// Delete a secret
107    Rm(KeyArgs),
108}
109
110#[derive(Subcommand)]
111pub enum WebsiteCommands {
112    /// Get the current URL
113    Get,
114    /// Set the current URL
115    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}