Skip to content
Open
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
17 changes: 16 additions & 1 deletion src/commands/suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
}

export async function suggestCommand(options: { commit?: boolean; autoCommit?: boolean } = {}): Promise<void> {
export async function suggestCommand(options: { commit?: boolean; autoCommit?: boolean; verbose?: boolean } = {}): Promise<void> {
intro(pc.bold(pc.cyan('commit-echo')));

try {
Expand All @@ -42,6 +42,11 @@
return;
}

if (options.verbose) {
console.log(pc.dim(` Model: ${config.model}`));
console.log(pc.dim(` Provider: ${config.provider}`));
}

let diffResult = getStagedDiff();

if (!diffResult.hasChanges) {
Expand All @@ -58,6 +63,14 @@
console.log(pc.dim(profileStr) + '\n');
}

if (options.verbose && profile.totalCommits > 0) {
console.log(pc.dim(` Style profile: ${profile.totalCommits} commits analyzed`));
console.log(pc.dim(` Avg length: ${profile.avgLength} chars`));
if (profile.imperativeRate !== undefined) {

Check warning on line 69 in src/commands/suggest.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/commands/suggest.ts#L69

Unnecessary conditional, the types have no overlap.
console.log(pc.dim(` Imperative mood rate: ${(profile.imperativeRate * 100).toFixed(0)}%`));
}
}

const genSpinner = spinner();
genSpinner.start('Generating commit suggestions...');

Expand All @@ -67,6 +80,8 @@

if (truncation) {
showTruncationWarning(truncation);
} else if (options.verbose) {
console.log(pc.dim(` Diff size: ${diffResult.diff.length} chars (no truncation needed)`));
}

await displaySuggestions(suggestions);
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ program
.option('--commit', 'Commit the selected suggestion', false)
.option('-y, --yes', 'Automatically select the first suggestion and skip prompts')
.option('--auto', 'Alias for --yes')
.option('-v, --verbose', 'Show verbose diagnostic info')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Register the -v, --verbose option on the root program so it is available globally, and ensure the root action passes the verbose option to the underlying suggest command.

.action(async (options) => {
await suggestCommand({ commit: options.commit, autoCommit: Boolean(options.yes || options.auto) });
await suggestCommand({ commit: options.commit, autoCommit: Boolean(options.yes || options.auto), verbose: Boolean(options.verbose) });
});

program
Expand Down