fleet/tools/github-manage/cmd/gm/main.go
George Karr ec2163768f
gkarr gm updates (#32625)
- **Adding sprint command to view items in current sprint and warning
when limit is too small**
- **Adding select / deselect all and demo output**
- **Added hotkey 's' to select all subissues along with the issue
selected**

Example of how I generated the demo docs for mdm this sprint
```
./gm sprint mdm --limit 200
'pressed l to select all issues'
'pressed w to select a workflow'
selected Bulk Demo workflow and hit enter
copy/paste features to features and bugs to bugs
modify gh usernames to @email and hit 'space' after every ) in the markdown to get it to trigger
hit tab for all issues listed under each user
...
profit
```
2025-09-05 16:28:36 -05:00

75 lines
1.9 KiB
Go

package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
"fleetdm/gm/pkg/ghapi"
"fleetdm/gm/pkg/logger"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
// promptToContinue asks the user if they want to continue or quit
func promptToContinue() bool {
fmt.Printf("\nPress Enter to continue, or type 'q' to quit: ")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
input := strings.TrimSpace(scanner.Text())
if strings.ToLower(input) == "q" || strings.ToLower(input) == "quit" {
fmt.Println("Exiting test...")
return false
}
return true
}
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)
}
}