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 {
Secrets {
#[command(subcommand)]
cmd: SecretsCommands,
},
Users {
#[command(subcommand)]
cmd: UserCommands,
},
Website {
#[command(subcommand)]
cmd: WebsiteCommands,
},
Login(LoginArgs),
Keygen(KeygenArgs),
Unseal {
chamber_key: String,
},
Upload(UploadArgs),
}
#[derive(Parser, Clone)]
pub struct LoginArgs {
#[arg(long, short = 'u')]
pub username: Option<String>,
#[arg(long, short = 'p')]
pub password: Option<String>,
}
#[derive(Parser, Clone)]
pub struct UserArgs {
#[arg(long, short = 'u')]
pub username: 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 {
#[arg(long, short = 'k')]
pub key: Option<String>,
#[arg(long, short = 'o')]
pub output: Option<PathBuf>,
}
#[derive(Parser, Clone)]
pub struct UpdateUserArgs {
pub username: String,
pub access_level: Option<i32>,
#[arg(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
pub roles: Option<Vec<String>>
}
#[derive(Subcommand)]
pub enum UserCommands {
Create(LoginArgs),
Update(UpdateUserArgs),
Delete(UserArgs),
}
#[derive(Subcommand)]
pub enum SecretsCommands {
Get(KeyArgs),
Set { key: String, value: String },
Update {
key: String,
#[arg(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
tags: Vec<String>,
},
List(ListArgs),
Rm(KeyArgs),
}
#[derive(Subcommand)]
pub enum WebsiteCommands {
Get,
Set(SetArgs),
}
#[derive(Parser, Clone)]
pub struct SetArgs {
#[arg(long, short = 'v')]
pub value: Option<String>
}
#[derive(Parser, Clone)]
pub struct UploadArgs {
#[arg(long, short)]
pub key: Option<String>,
}