Skip to content

Commit bdd16bc

Browse files
committed
Introduce stage option and git staging helper
## CLI Arguments - Introduced stage flag to stage all changes before generating commit messages. - Introduced -w shorthand for --apply to write the commit editmsg. - Introduced -m shorthand for --model to specify the model quickly. - Introduced -k shorthand for OPENAI_API_KEY for the API key. ## Git - Introduced stage_all helper to stage all new, modified, and deleted files (git add -A). ## Main - Wired new stage flag into startup sequence: if cli.stage { stage_all()?; } and imported stage_all for use before LLM client setup.
1 parent 6a088dd commit bdd16bc

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/cli_args.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@ pub struct Cli {
1818
pub ask: bool,
1919

2020
/// If set, write the generated message into .git/COMMIT_EDITMSG (no commit is created)
21-
#[arg(long, global = true)]
21+
#[arg(short = 'w', long, global = true)]
2222
pub apply: bool,
2323

24+
/// Stage all changes before generating the commit message
25+
#[arg(short, long, global = true)]
26+
pub stage: bool,
27+
2428
/// Debug mode: log prompts, responses, token usage
2529
#[arg(long, global = true)]
2630
pub debug: bool,
2731

2832
/// Model name to use (e.g. gpt-4o-mini). If 'none', acts like --no-model.
29-
#[arg(long, global = true)]
33+
#[arg(short, long, global = true)]
3034
pub model: Option<String>,
3135

3236
/// Disable model calls; return dummy responses instead
3337
#[arg(long, global = true)]
3438
pub no_model: bool,
3539

3640
/// API key (otherwise uses OPENAI_API_KEY env var)
37-
#[arg(long, env = "OPENAI_API_KEY", global = true)]
41+
#[arg(short = 'k', long, env = "OPENAI_API_KEY", global = true)]
3842
pub api_key: Option<String>,
3943

4044
/// Optional: a brief human description of the ticket (for commit/PR summaries)

src/git.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,9 @@ pub fn collect_pr_items(base: &str, from: &str) -> Result<Vec<PrItem>> {
185185

186186
Ok(items)
187187
}
188+
189+
/// Stage all new, modified, and deleted files
190+
pub fn stage_all() -> Result<()> {
191+
git_output(&["add", "-A"])?;
192+
Ok(())
193+
}

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use clap::Parser;
99
use config::Config;
1010
use crate::cli_args::{Cli, Command};
1111
use crate::git::{current_branch, staged_diff, staged_files, staged_diff_for_file,
12-
write_commit_editmsg, collect_pr_items, PrSummaryMode};
12+
write_commit_editmsg, collect_pr_items, PrSummaryMode, stage_all};
1313
use crate::llm::LlmClient;
1414

1515
use std::collections::HashSet;
@@ -347,6 +347,11 @@ fn main() -> Result<()> {
347347
let cli = Cli::parse();
348348
let cfg = Config::from_sources(&cli);
349349

350+
// Pre-Work Items
351+
if cli.stage {
352+
stage_all()?;
353+
}
354+
350355
// LLM client setup
351356
let boxed_client = setup::build_llm_client(&cli, &cfg);
352357

0 commit comments

Comments
 (0)