Skip to main content

commit_wizard/cli/cmd/commit/
mod.rs

1use clap::Args as ClapArgs;
2
3use crate::{
4    cli::CliResult,
5    core::{commit, context::Context},
6};
7
8#[derive(Debug, Clone, ClapArgs)]
9#[command(about = "Create a structured Git commit using the active Commit Wizard rules")]
10pub struct Args {
11    /// Allow committing with no staged changes
12    #[arg(long)]
13    pub allow_empty: bool,
14    /// Conventional Commit type (feat, fix, etc.)
15    #[arg(long = "type", short = 't')]
16    pub commit_type: Option<String>,
17    /// Commit Scope (Optional)
18    #[arg(long, short = 's')]
19    pub scope: Option<String>,
20    /// Commit Short Summary (72 chars)
21    #[arg(long, short = 'm')]
22    pub message: Option<String>,
23    /// Breaking Change Boolean
24    #[arg(long, short = 'B', default_value = "false")]
25    pub breaking: bool,
26    /// Breaking Change Message (Optional)
27    #[arg(long, short = 'd')]
28    pub breaking_message: Option<String>,
29    /// Commit Message Body (Optional)
30    #[arg(long, short = 'b')]
31    pub body: Option<String>,
32    /// Commit Message Footer (can be stacked with -f "Author: Wizard" -f "Co-Author: Cat")
33    #[arg(long, short = 'f')]
34    pub footer: Vec<String>,
35}
36
37pub async fn run(ctx: &Context, args: Args) -> CliResult<()> {
38    commit::make::run(
39        ctx,
40        args.allow_empty,
41        args.commit_type,
42        args.scope,
43        args.message,
44        args.breaking,
45        args.breaking_message,
46        args.body,
47        args.footer,
48    )
49}