fleet/tools/github-manage/cmd/gm/main.go
George Karr 3c687f2ed9
Adding direction to add views and workflows (#33177)
This looks like a log but it's just moving the code that lived in
cmd/gm/ui.go into it's own pkg that makes it clearer where each part of
the UI lives.

I am also adding the functionality for bulk sprint demo to grab names
from github usernames.
2025-09-25 14:05:39 -05:00

59 lines
1.5 KiB
Go

package main
import (
"fmt"
"log"
"fleetdm/gm/pkg/ghapi"
"fleetdm/gm/pkg/logger"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func main() {
// Initialize logger
if err := logger.Init(); err != nil {
log.Fatalf("Failed to initialize logger: %v", err)
}
rootCmd := &cobra.Command{
Use: "gm",
Short: "GitHub Manage CLI",
Long: "A CLI tool to manage GitHub repositories and workflows.",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
cmdSent := fmt.Sprintf("Command: %s Args: %v Flags: ", cmd.CommandPath(), args)
cmd.Flags().VisitAll(func(flag *pflag.Flag) {
if flag.Changed {
cmdSent = fmt.Sprintf("%s --%s: %s", cmdSent, flag.Name, flag.Value.String())
}
})
logger.Debugf("%s", cmdSent)
},
Run: func(cmd *cobra.Command, args []string) {
// Placeholder for the default command behavior
logger.Info("Welcome to GitHub Manage CLI!")
cmd.Usage()
},
}
rootCmd.AddCommand(issuesCmd)
rootCmd.AddCommand(projectCmd)
rootCmd.AddCommand(estimatedCmd)
rootCmd.AddCommand(sprintCmd)
// Test command to test SetCurrentSprint functionality
rootCmd.AddCommand(&cobra.Command{
Use: "test",
Short: "Test SetCurrentSprint functionality",
Run: func(cmd *cobra.Command, args []string) {
// Useful to test new custom functions
testIssueNumber := 31541
ghapi.GetIssues(fmt.Sprintf("%d", testIssueNumber))
},
})
if err := rootCmd.Execute(); err != nil {
log.Fatalf("Error executing command: %v", err)
}
}