use anyhow::Result;
use clap::{Parser, Subcommand};
mod commands;
mod completions;
mod config;
mod profile;
#[derive(Parser)]
#[command(name = "kraven")]
#[command(author, version, about = "Manage named environment variable profiles")]
#[command(arg_required_else_help = true)]
pub struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Activate {
profile: String,
},
Deactivate,
#[command(visible_alias = "ls")]
List,
Edit {
profile: String,
},
Show {
profile: String,
#[arg(short, long)]
mask: bool,
},
#[command(visible_alias = "rm")]
Remove {
profile: String,
#[arg(short, long)]
force: bool,
},
Encrypt {
profile: String,
},
Decrypt {
profile: String,
},
Current,
Completions,
}
fn main() -> Result<()> {
completions::init();
let cli = Cli::parse();
match cli.command {
Commands::Activate { profile } => commands::activate::run(&profile),
Commands::Deactivate => commands::deactivate::run(),
Commands::List => commands::list::run(),
Commands::Edit { profile } => commands::edit::run(&profile),
Commands::Show { profile, mask } => commands::show::run(&profile, mask),
Commands::Remove { profile, force } => commands::remove::run(&profile, force),
Commands::Encrypt { profile } => commands::encrypt::run(&profile),
Commands::Decrypt { profile } => commands::decrypt::run(&profile),
Commands::Current => commands::current::run(),
Commands::Completions => commands::completions::run(),
}
}