Skip to content

Commit 446eedf

Browse files
authored
Merge pull request #125 from aqsaaqeel/fix/toggle-flag-unused
Feat: Add verbose mode for debugging and diff stats
2 parents 9138c7b + fe66422 commit 446eedf

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

cmd/cli/createMsg.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import (
2323
// CreateCommitMsg launches the interactive flow for reviewing, regenerating,
2424
// editing, and accepting AI-generated commit messages in the current repo.
2525
// If dryRun is true, it displays the prompt without making an API call.
26-
func CreateCommitMsg(Store *store.StoreMethods, dryRun bool, autoCommit bool) {
26+
// If verbose is true, shows detailed diff statistics and processing info.
27+
func CreateCommitMsg(Store *store.StoreMethods, dryRun bool, autoCommit bool, verbose bool) {
2728
// Validate COMMIT_LLM and required API keys
2829
useLLM, err := Store.DefaultLLMKey()
2930
if err != nil {
@@ -67,6 +68,12 @@ func CreateCommitMsg(Store *store.StoreMethods, dryRun bool, autoCommit bool) {
6768
pterm.Println()
6869
display.ShowFileStatistics(fileStats)
6970

71+
if verbose {
72+
pterm.Info.Printf("Repository: %s\n", currentDir)
73+
pterm.Info.Printf("File summary: %d staged, %d unstaged, %d untracked\n",
74+
len(fileStats.StagedFiles), len(fileStats.UnstagedFiles), len(fileStats.UntrackedFiles))
75+
}
76+
7077
if fileStats.TotalFiles == 0 {
7178
pterm.Warning.Println("No changes detected in the Git repository.")
7279
pterm.Info.Println("Tips:")
@@ -124,12 +131,16 @@ func CreateCommitMsg(Store *store.StoreMethods, dryRun bool, autoCommit bool) {
124131

125132
pterm.Info.Printf("Truncated diff to %d lines, %d characters.\n", actualLineCount, len(changes))
126133
pterm.Info.Println("Consider committing smaller changes for more accurate commit messages.")
134+
} else if verbose {
135+
pterm.Info.Printf("Diff statistics: %d lines, %d characters (within limits).\n", len(diffLines), len(changes))
136+
inputTokens := estimateTokens(changes)
137+
pterm.Info.Printf("Estimated tokens for LLM: %d input tokens.\n", inputTokens)
127138
}
128139

129140
// Handle dry-run mode: display what would be sent to LLM without making API call
130141
if dryRun {
131142
pterm.Println()
132-
displayDryRunInfo(commitLLM, config, changes, apiKey)
143+
displayDryRunInfo(commitLLM, config, changes, apiKey, verbose)
133144
return
134145
}
135146

@@ -561,7 +572,7 @@ func displayMissingCredentialHint(provider types.LLMProvider) {
561572
}
562573

563574
// displayDryRunInfo shows what would be sent to the LLM without making an API call
564-
func displayDryRunInfo(provider types.LLMProvider, config *types.Config, changes string, apiKey string) {
575+
func displayDryRunInfo(provider types.LLMProvider, config *types.Config, changes string, apiKey string, verbose bool) {
565576
pterm.DefaultHeader.WithFullWidth().
566577
WithBackgroundStyle(pterm.NewStyle(pterm.BgBlue)).
567578
WithTextStyle(pterm.NewStyle(pterm.FgWhite, pterm.Bold)).
@@ -633,11 +644,17 @@ func displayDryRunInfo(provider types.LLMProvider, config *types.Config, changes
633644
}
634645

635646
statsData = append(statsData, []string{"Estimated Processing Time", fmt.Sprintf("%d-%d seconds", minTime, maxTime)})
647+
if verbose {
648+
statsData = append(statsData, []string{"Prompt Length", fmt.Sprintf("%d characters", len(prompt))})
649+
}
636650

637651
pterm.DefaultTable.WithHasHeader(false).WithData(statsData).Render()
638652

639653
pterm.Println()
640654
pterm.Success.Println("Dry-run complete. To generate actual commit message, run without --dry-run flag.")
655+
if !verbose {
656+
pterm.Info.Println("Use --toggle flag to see debug details.")
657+
}
641658
}
642659

643660
// maskAPIKey masks the API key for display purposes

cmd/cli/root.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ var rootCmd = &cobra.Command{
2929
3030
# Generate a commit message and automatically commit it
3131
commit . --auto
32+
33+
# Show verbose debug information (diff stats, full prompts, repository details)
34+
commit . --toggle
35+
commit . --dry-run --toggle
3236
`,
3337
// Uncomment the following line if your bare application
3438
// has an action associated with it:
@@ -108,7 +112,13 @@ var creatCommitMsg = &cobra.Command{
108112
if err != nil {
109113
return err
110114
}
111-
CreateCommitMsg(Store, dryRun, autoCommit)
115+
116+
verbose, err := cmd.Flags().GetBool("toggle")
117+
if err != nil {
118+
return err
119+
}
120+
121+
CreateCommitMsg(Store, dryRun, autoCommit, verbose)
112122
return nil
113123
},
114124
}
@@ -123,11 +133,10 @@ func init() {
123133
// Cobra also supports local flags, which will only run
124134
// when this action is called directly.
125135

126-
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
127-
128-
// Add --dry-run and --auto as persistent flags so they show in top-level help
136+
// Add --dry-run, --auto, and --toggle as persistent flags so they show in top-level help
129137
rootCmd.PersistentFlags().Bool("dry-run", false, "Preview the prompt that would be sent to the LLM without making an API call")
130138
rootCmd.PersistentFlags().Bool("auto", false, "Automatically commit with the generated message")
139+
rootCmd.PersistentFlags().BoolP("toggle", "t", false, "Show verbose debug information (diff stats, full prompts, repository details)")
131140

132141
rootCmd.AddCommand(creatCommitMsg)
133142
rootCmd.AddCommand(llmCmd)

0 commit comments

Comments
 (0)