MCPcopy Create free account
hub / github.com/github/gh-aw / NewListCommand

Function NewListCommand

pkg/cli/list_workflows_command.go:29–81  ·  view source on GitHub ↗

NewListCommand creates the list command

()

Source from the content-addressed store, hash-verified

27
28// NewListCommand creates the list command
29func NewListCommand() *cobra.Command {
30 cmd := &cobra.Command{
31 Use: "list [pattern]",
32 Short: "List agentic workflows in the repository",
33 Long: `List all agentic workflows in a repository without checking their status.
34
35Displays a simplified table with workflow name, AI engine, and compilation status.
36Unlike 'status', this command does not check GitHub workflow state or time remaining.
37
38The optional pattern argument filters workflows by name (case-insensitive substring match).
39It accepts workflow IDs (basename without .md) or full filenames.`,
40 Example: ` ` + string(constants.CLIExtensionPrefix) + ` list # List all workflows in current repo
41 ` + string(constants.CLIExtensionPrefix) + ` list --repo github/gh-aw # List workflows from github/gh-aw repo
42 ` + string(constants.CLIExtensionPrefix) + ` list --repo org/repo --path workflows # List from custom path
43 ` + string(constants.CLIExtensionPrefix) + ` list --dir custom/workflows # List from custom local directory
44 ` + string(constants.CLIExtensionPrefix) + ` list ci- # List workflows with 'ci-' in name
45 ` + string(constants.CLIExtensionPrefix) + ` list --repo github/gh-aw ci- # List workflows from github/gh-aw with 'ci-' in name
46 ` + string(constants.CLIExtensionPrefix) + ` list --json # Output in JSON format
47 ` + string(constants.CLIExtensionPrefix) + ` list --label automation # List workflows with 'automation' label`,
48 RunE: func(cmd *cobra.Command, args []string) error {
49 var pattern string
50 if len(args) > 0 {
51 pattern = args[0]
52 }
53
54 repo, _ := cmd.Flags().GetString("repo")
55 path, _ := cmd.Flags().GetString("path")
56 dir, _ := cmd.Flags().GetString("dir")
57 verbose, _ := cmd.Flags().GetBool("verbose")
58 jsonFlag, _ := cmd.Flags().GetBool("json")
59 labelFilter, _ := cmd.Flags().GetString("label")
60
61 // --dir overrides the local workflow directory when no remote repo is specified.
62 // When --repo is set, --path is used for the remote repository path instead.
63 if dir != "" && repo == "" {
64 path = dir
65 }
66 return RunListWorkflows(repo, path, pattern, verbose, jsonFlag, labelFilter)
67 },
68 }
69
70 addRepoFlag(cmd)
71 addJSONFlag(cmd)
72 cmd.Flags().String("label", "", "Filter workflows by label")
73 cmd.Flags().String("path", constants.GetWorkflowDir(), "Path to workflows directory in the remote repository (used with --repo)")
74 cmd.Flags().StringP("dir", "d", "", "Workflow directory (default: $GH_AW_WORKFLOWS_DIR or .github/workflows; ignored when --repo is set)")
75
76 // Register completions for list command
77 cmd.ValidArgsFunction = CompleteWorkflowNames
78 RegisterDirFlagCompletion(cmd, "dir")
79
80 return cmd
81}
82
83// RunListWorkflows lists workflows without checking GitHub status
84func RunListWorkflows(repo, path, pattern string, verbose bool, jsonOutput bool, labelFilter string) error {

Callers 2

initFunction · 0.92
TestNewListCommandFunction · 0.85

Calls 7

GetWorkflowDirFunction · 0.92
RunListWorkflowsFunction · 0.85
addRepoFlagFunction · 0.85
addJSONFlagFunction · 0.85
GetStringMethod · 0.65
StringMethod · 0.45

Tested by 1

TestNewListCommandFunction · 0.68