1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use clap::{ArgAction, Parser, Subcommand};
/// CLI options
#[derive(Parser, Debug)]
#[command(
name = "commitbot",
disable_version_flag = true,
about = "LLM-assisted Git commit message generator"
)]
pub struct Cli {
/// Interactive mode: classify each file and do per-file summaries
#[arg(long, global = true)]
pub ask: bool,
/// Stage all changes before generating the commit message
#[arg(short, long, global = true)]
pub stage: bool,
/// Max concurrent requests to the LLM API
#[arg(long, global = true)]
pub max: Option<usize>,
/// Model name to use (e.g. gpt-4o-mini)
#[arg(short, long, global = true)]
pub model: Option<String>,
/// API key (otherwise uses OPENAI_API_KEY env var)
#[arg(short = 'k', long, global = true)]
pub api_key: Option<String>,
/// LLM provider / API style (openai or ollama)
#[arg(long, global = true)]
pub provider: Option<String>,
/// Base URL for the selected provider (e.g. http://localhost:11434) llama3.1:8b-instruct-q5_K_M
#[arg(long, global = true)]
pub url: Option<String>,
/// Read diff from a file instead of git staged changes (use "-" for stdin).
/// Cannot be used with --ask mode.
#[arg(long, global = true, value_name = "FILE")]
pub diff: Option<String>,
/// Branch name to use in the commit message context (used with --diff).
/// If not specified when using --diff, defaults to the current branch.
#[arg(long, global = true)]
pub branch: Option<String>,
/// Disable streaming responses (streaming is on by default)
#[arg(long, global = true)]
pub no_stream: bool,
/// Increase verbosity (-v, -vv, -vvv)
#[arg(short = 'v', long = "verbose", action = ArgAction::Count)]
pub verbose: u8,
/// Define config file (default: ~/.config/commitbot.toml)
#[arg(long, global = true, value_name = "FILE")]
pub config: Option<String>,
/// Subcommand (e.g. 'pr')
#[command(subcommand)]
pub command: Option<Command>,
/// Print only the version number (e.g. "0.5.1"). This replaces clap's auto --version output.
#[arg(long, global = true, action = ArgAction::SetTrue)]
pub version: bool,
}
/// Subcommands, e.g. `commitbot pr develop`
#[derive(Subcommand, Debug)]
pub enum Command {
/// Generate a Pull Request description by summarizing commit or PR messages
///
/// This command analyzes a commit range and generates a PR summary.
/// Example:
/// commitbot pr --base main --from feature-branch
Pr {
/// Base branch to compare against (e.g. main or develop)
base: String,
/// Optional feature/source branch; defaults to current branch if omitted
from: Option<String>,
/// Force using PR-oriented grouping (PR numbers) instead of commits
#[arg(long = "pr")]
pr_mode: bool,
/// Force using commit-by-commit mode instead of PR grouping
#[arg(long = "commit")]
commit_mode: bool,
},
/// Freeform summary provided at the end of the command.
///
/// Example:
/// commitbot summary "fix: correct typo in documentation"
#[command(external_subcommand)]
Summary(Vec<String>),
}