-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
64 lines (55 loc) · 1.9 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"os"
"github.com/belingud/gptcomet/cmd"
"github.com/belingud/gptcomet/internal/debug"
"github.com/spf13/cobra"
)
var version = "2.1.1"
// main is the entry point of the GPTComet application. It initializes and configures the command-line interface
// using cobra. The following commands are available:
//
// - provider: Manage AI providers configuration
// - commit: Generate commit messages using AI
// - config: Manage application configuration
// - update: Check and update to latest version
// - review: Review git changes and commit messages
//
// The root command supports the following persistent flags:
//
// --debug, -d: Enable debug mode for verbose logging
// --config, -c: Specify a custom config file path
//
// If command execution fails, the program exits with status code 1.
func main() {
var (
debugEnabled bool
configPath string
)
var rootCmd = &cobra.Command{
Use: "gmsg",
Aliases: []string{"gptcomet"},
Short: "GPTComet - AI-powered Git commit message generator and reviewer",
Version: version,
SilenceUsage: true,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
debug.Enable(debugEnabled)
debug.Printf("Debug mode enabled")
if configPath != "" {
debug.Printf("Using config file: %s", configPath)
}
},
}
// Add persistent flags to root command
rootCmd.PersistentFlags().BoolVarP(&debugEnabled, "debug", "d", false, "Enable debug mode")
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "Config file path")
rootCmd.AddCommand(cmd.NewProviderCmd()) // newprovider
rootCmd.AddCommand(cmd.NewCommitCmd()) // commit
rootCmd.AddCommand(cmd.NewConfigCmd()) // config
rootCmd.AddCommand(cmd.NewUpdateCmd(version)) // update
rootCmd.AddCommand(cmd.NewReviewCmd()) // review
if err := rootCmd.Execute(); err != nil {
// fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}