mirror of
https://github.com/fleetdm/fleet
synced 2026-05-06 14:58:33 +00:00
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.
82 lines
2.2 KiB
Go
82 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"fleetdm/gm/pkg/ghapi"
|
|
"fleetdm/gm/pkg/tui"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var projectCmd = &cobra.Command{
|
|
Use: "project [project-id-or-alias]",
|
|
Short: "Get GitHub issues from a project",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
projectID, err := ghapi.ResolveProjectID(args[0])
|
|
if err != nil {
|
|
fmt.Printf("Error resolving project: %v\n", err)
|
|
return
|
|
}
|
|
|
|
limit, err := cmd.Flags().GetInt("limit")
|
|
if err != nil {
|
|
fmt.Printf("Error getting limit flag: %v\n", err)
|
|
return
|
|
}
|
|
|
|
tui.RunTUI(tui.ProjectCommand, projectID, limit, "")
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
projectCmd.Flags().IntP("limit", "l", 100, "Maximum number of items to fetch")
|
|
estimatedCmd.Flags().IntP("limit", "l", 500, "Maximum number of items to fetch from drafting project")
|
|
sprintCmd.Flags().IntP("limit", "l", 100, "Maximum number of items to fetch")
|
|
}
|
|
|
|
var estimatedCmd = &cobra.Command{
|
|
Use: "estimated [project-id-or-alias]",
|
|
Short: "Get estimated GitHub issues from the drafting project filtered by project label",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
projectID, err := ghapi.ResolveProjectID(args[0])
|
|
if err != nil {
|
|
fmt.Printf("Error resolving project: %v\n", err)
|
|
return
|
|
}
|
|
|
|
limit, err := cmd.Flags().GetInt("limit")
|
|
if err != nil {
|
|
fmt.Printf("Error getting limit flag: %v\n", err)
|
|
return
|
|
}
|
|
|
|
tui.RunTUI(tui.EstimatedCommand, projectID, limit, "")
|
|
},
|
|
}
|
|
|
|
// sprintCmd fetches only the issues currently in the active sprint for a project.
|
|
// Usage mirrors the project command but filters to items whose sprint field matches the
|
|
// current iteration (using the already implemented @current logic when setting sprint).
|
|
var sprintCmd = &cobra.Command{
|
|
Use: "sprint [project-id-or-alias]",
|
|
Short: "Get GitHub issues in the current sprint for a project",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
projectID, err := ghapi.ResolveProjectID(args[0])
|
|
if err != nil {
|
|
fmt.Printf("Error resolving project: %v\n", err)
|
|
return
|
|
}
|
|
|
|
limit, err := cmd.Flags().GetInt("limit")
|
|
if err != nil {
|
|
fmt.Printf("Error getting limit flag: %v\n", err)
|
|
return
|
|
}
|
|
|
|
tui.RunTUI(tui.SprintCommand, projectID, limit, "")
|
|
},
|
|
}
|