Skip to content

Commit 5c0924d

Browse files
committed
fix: add yes flag to auto-commit with default message
1 parent 88cd482 commit 5c0924d

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

cmd/generate.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ import (
1414
"github.com/spf13/cobra"
1515
)
1616

17+
var yesFlag bool
18+
1719
var GenerateCmd = &cobra.Command{
1820
Use: "generate",
1921
Short: "Generate a commit message using AI",
22+
Long: `Generate a commit message from staged Git changes using a local or remote LLM.
23+
24+
By default, it launches an interactive flow.
25+
Use --yes or -y to skip the prompt and commit directly.`,
2026
Run: func(cmd *cobra.Command, args []string) {
2127
cfg := config.LoadOrDefault()
2228

@@ -40,6 +46,15 @@ var GenerateCmd = &cobra.Command{
4046
return
4147
}
4248

49+
if yesFlag {
50+
fmt.Println("💡 Generated Commit Message:")
51+
fmt.Println("----------------------------------")
52+
fmt.Println(message)
53+
fmt.Println("----------------------------------")
54+
runGitCommit(message)
55+
return
56+
}
57+
4358
for {
4459
fmt.Println("\n💡 Generated Commit Message:")
4560
fmt.Println("----------------------------------")
@@ -76,6 +91,10 @@ var GenerateCmd = &cobra.Command{
7691
},
7792
}
7893

94+
func init() {
95+
GenerateCmd.Flags().BoolVarP(&yesFlag, "yes", "y", false, "Autogenerate and commit without prompting")
96+
}
97+
7998
func runGitCommit(msg string) {
8099
fmt.Println("✅ Committing with:")
81100
fmt.Println(msg)

0 commit comments

Comments
 (0)