@@ -33,19 +33,24 @@ func main() {
33
33
cmd .Help ()
34
34
return
35
35
}
36
- var newBranch , message string
37
- cmd .Flags ().StringVarP (& message , "message" , "m" , "" , "Auto generate commit message" )
38
- cmd .Flags ().StringVarP (& newBranch , "newBranch" , "b" , "" , "Auto generate branch name" )
39
- err := cmd .Flags ().Parse (args )
36
+
40
37
if err == nil || strings .Contains (err .Error (), "flag needs an argument" ) {
41
38
// Handle specific commands
42
39
switch args [0 ] {
43
40
case "commit" :
41
+ var message string
42
+ var all bool
43
+ cmd .Flags ().StringVarP (& message , "message" , "m" , "" , "Auto generate commit message" )
44
+ cmd .Flags ().BoolVarP (& all , "all" , "a" , false , "Auto add all to stage" )
45
+ err := cmd .Flags ().Parse (args )
44
46
if err != nil && strings .Contains (err .Error (), "flag needs an argument" ) && message == "" {
45
- handleCommit (* config )
47
+ handleCommit (* config , all )
46
48
return
47
49
}
48
50
case "checkout" :
51
+ var newBranch string
52
+ cmd .Flags ().StringVarP (& newBranch , "newBranch" , "b" , "" , "Auto generate branch name" )
53
+ err := cmd .Flags ().Parse (args )
49
54
if err != nil && strings .Contains (err .Error (), "flag needs an argument" ) && newBranch == "" {
50
55
handleCheckout (* config )
51
56
return
@@ -73,7 +78,7 @@ func main() {
73
78
}
74
79
}
75
80
76
- func handleCommit (config ai.Config ) {
81
+ func handleCommit (config ai.Config , addAll bool ) {
77
82
// Get detailed git changes information
78
83
changes , err := git .GetChanges ()
79
84
if err != nil {
@@ -148,9 +153,12 @@ func handleCommit(config ai.Config) {
148
153
fmt .Println ("Commit message is empty. Commit cancelled." )
149
154
return
150
155
}
151
-
156
+ arg := "-m"
157
+ if addAll {
158
+ arg = "-am"
159
+ }
152
160
// Execute git commit with the edited message
153
- commitCmd := exec .Command ("git" , "commit" , "-m" , message )
161
+ commitCmd := exec .Command ("git" , "commit" , arg , message )
154
162
commitCmd .Stdout = os .Stdout
155
163
commitCmd .Stderr = os .Stderr
156
164
0 commit comments