Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/smartcommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ program
.version(pkg.version)
.option("--ai", "Enhance commit message using AI")
.option("--auto", "Auto accept commit without confirmation")
.option("--model <name>", "Specify Ollama model");
.option("--model <name>", "Specify Ollama model")
.option("--dry-run", "Print the generated commit message and exit without committing");
program.action(async (options) => {
await run(options);
});
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface CliOptions {
ai?: boolean;
model?: string;
auto?: boolean;
dryRun?: boolean;
[key: string]: unknown;
}

Expand Down Expand Up @@ -134,6 +135,12 @@ export async function run(options: CliOptions) {
process.exit(1);
}

// Dry run: print message and exit without committing
if (options.dryRun) {
console.log("\n" + commitMessage + "\n");
process.exit(0);
}

// Confirmation flow
let finalMessage: string;

Expand Down