
- Add comprehensive Git workflow automation tools - Include branch management utilities - Add commit helpers with conventional commit support - Implement GitHub integration for PR management - Add configuration management system - Include comprehensive test coverage - Add professional documentation and examples
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"github.com/spf13/cobra"
|
|
"github.com/iwasforcedtobehere/git-automation-cli/internal/version"
|
|
"github.com/iwasforcedtobehere/git-automation-cli/internal/config"
|
|
)
|
|
|
|
var (
|
|
verbose bool
|
|
dryRun bool
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "gitauto",
|
|
Short: "Git automation toolkit",
|
|
Long: `Git Automation CLI is a fast, practical tool to automate frequent Git workflows.
|
|
It provides utilities for branch management, commit helpers, sync operations,
|
|
and integration with GitHub for pull requests and team coordination.`,
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
// Initialize configuration
|
|
if err := config.Init(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error initializing configuration: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Override config with command line flags
|
|
if verbose {
|
|
config.Set("verbose", true)
|
|
}
|
|
if dryRun {
|
|
config.Set("dry_run", true)
|
|
}
|
|
},
|
|
}
|
|
|
|
var versionCmd = &cobra.Command{
|
|
Use: "version",
|
|
Short: "Print the version information",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
fmt.Println("gitauto version", version.GetVersion())
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(versionCmd)
|
|
|
|
// Add global flags
|
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")
|
|
rootCmd.PersistentFlags().BoolVar(&dryRun, "dry-run", false, "dry run mode (no changes made)")
|
|
}
|
|
|
|
func Execute() {
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|