use clap::{Args as ClapArgs, Subcommand};
use crate::{
cli::CliResult,
core::{configs, context::Context},
};
#[derive(Debug, Clone, ClapArgs)]
#[command(about = "Inspect and manage Commit Wizard configuration")]
pub struct Args {
#[arg(short = 'g', long = "global", conflicts_with = "config")]
pub global: bool,
#[command(subcommand)]
pub subcommand: ConfigSubcommand,
}
#[derive(Debug, Clone, Subcommand)]
pub enum ConfigSubcommand {
Path,
Show {
},
Get {
key: String,
},
Set {
key: String,
value: String,
},
Unset {
key: String,
},
}
pub async fn run(ctx: &Context, args: Args) -> CliResult<()> {
let global = args.global;
match args.subcommand {
ConfigSubcommand::Path => configs::config_path(ctx, global),
ConfigSubcommand::Show {} => configs::config_show(ctx, global),
ConfigSubcommand::Get { key } => configs::config_get(ctx, &key, global),
ConfigSubcommand::Set { key, value, .. } => configs::config_set(ctx, &key, &value, global),
ConfigSubcommand::Unset { key } => configs::config_unset(ctx, &key, global),
}
}