fleet/tools/github-manage/cmd/gm/main.go
Ian Littman 9ce3182726
Add bug open time metric calculation to gm, including milestone exclusion (#39118)
This matches our current bug open time KPI calculation, with the added
ability to exclude milestones from the calculation. Milestone exclusion
allows for easily answering the question "what would happen to the
metric if we released this milestone today?"

Verbose output lists each bug, net of filtering by milestone, including
the product group label associated with the bug (so we can spot cases
where a bug won't get resolved all else equal because it isn't triaged
to a current product group).
2026-02-03 17:59:45 -06:00

63 lines
1.6 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)
rootCmd.AddCommand(milestoneCmd)
rootCmd.AddCommand(releasesCmd)
rootCmd.AddCommand(preSprintCmd)
rootCmd.AddCommand(bugsCmd)
// 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)
}
}