commit_wizard/cli/cmd/config/
mod.rs1use clap::{Args as ClapArgs, Subcommand};
2
3use crate::{
4 cli::CliResult,
5 core::{configs, context::Context},
6};
7
8#[derive(Debug, Clone, ClapArgs)]
9#[command(about = "Inspect and manage Commit Wizard configuration")]
10pub struct Args {
11 #[arg(short = 'g', long = "global", conflicts_with = "config")]
13 pub global: bool,
14 #[command(subcommand)]
15 pub subcommand: ConfigSubcommand,
16}
17
18#[derive(Debug, Clone, Subcommand)]
19pub enum ConfigSubcommand {
20 Path,
22 Show {
24 },
28 Get {
30 key: String,
32 },
33 Set {
35 key: String,
37 value: String,
39 },
40 Unset {
42 key: String,
44 },
45 }
48
49pub async fn run(ctx: &Context, args: Args) -> CliResult<()> {
50 let global = args.global;
51 match args.subcommand {
52 ConfigSubcommand::Path => configs::config_path(ctx, global),
53 ConfigSubcommand::Show {} => configs::config_show(ctx, global),
54 ConfigSubcommand::Get { key } => configs::config_get(ctx, &key, global),
55 ConfigSubcommand::Set { key, value, .. } => configs::config_set(ctx, &key, &value, global),
56 ConfigSubcommand::Unset { key } => configs::config_unset(ctx, &key, global),
57 }
58}