NewStatusCommand creates the status command
()
| 7 | |
| 8 | // NewStatusCommand creates the status command |
| 9 | func NewStatusCommand() *cobra.Command { |
| 10 | cmd := &cobra.Command{ |
| 11 | Use: "status [pattern]", |
| 12 | Short: "Show status of all agentic workflows in the repository", |
| 13 | Long: `Show status of all agentic workflows in the repository. |
| 14 | |
| 15 | Displays a table with workflow name, AI engine, compilation status, enabled/disabled state, |
| 16 | and time remaining until expiration (if stop-after is configured). |
| 17 | |
| 18 | The optional pattern argument filters workflows by name (case-insensitive substring match). |
| 19 | It accepts workflow IDs (basename without .md) or full filenames.`, |
| 20 | Example: ` ` + string(constants.CLIExtensionPrefix) + ` status # Show all workflow status |
| 21 | ` + string(constants.CLIExtensionPrefix) + ` status ci- # Show workflows with 'ci-' in name |
| 22 | ` + string(constants.CLIExtensionPrefix) + ` status --json # Output in JSON format |
| 23 | ` + string(constants.CLIExtensionPrefix) + ` status --ref main # Show latest run status for main branch |
| 24 | ` + string(constants.CLIExtensionPrefix) + ` status --label automation # Show workflows with 'automation' label |
| 25 | ` + string(constants.CLIExtensionPrefix) + ` status --repo owner/other-repo # Check status in different repository`, |
| 26 | RunE: func(cmd *cobra.Command, args []string) error { |
| 27 | var pattern string |
| 28 | if len(args) > 0 { |
| 29 | pattern = args[0] |
| 30 | } |
| 31 | verbose, _ := cmd.Flags().GetBool("verbose") |
| 32 | jsonFlag, _ := cmd.Flags().GetBool("json") |
| 33 | ref, _ := cmd.Flags().GetString("ref") |
| 34 | labelFilter, _ := cmd.Flags().GetString("label") |
| 35 | repoOverride, _ := cmd.Flags().GetString("repo") |
| 36 | statusLog.Printf("Status command invoked: pattern=%q, json=%v, ref=%q, label=%q, repo=%q", pattern, jsonFlag, ref, labelFilter, repoOverride) |
| 37 | return StatusWorkflows(pattern, verbose, jsonFlag, ref, labelFilter, repoOverride) |
| 38 | }, |
| 39 | } |
| 40 | |
| 41 | addJSONFlag(cmd) |
| 42 | cmd.Flags().StringP("repo", "r", "", "Target repository ([HOST/]owner/repo format). Defaults to current repository") |
| 43 | cmd.Flags().String("ref", "", "Filter runs by branch or tag name (e.g., main, v1.0.0)") |
| 44 | cmd.Flags().String("label", "", "Filter workflows by label") |
| 45 | |
| 46 | // Register completions for status command |
| 47 | cmd.ValidArgsFunction = CompleteWorkflowNames |
| 48 | |
| 49 | return cmd |
| 50 | } |