RunListWorkflows lists workflows without checking GitHub status
(repo, path, pattern string, verbose bool, jsonOutput bool, labelFilter string)
| 82 | |
| 83 | // RunListWorkflows lists workflows without checking GitHub status |
| 84 | func RunListWorkflows(repo, path, pattern string, verbose bool, jsonOutput bool, labelFilter string) error { |
| 85 | listWorkflowsLog.Printf("Listing workflows: repo=%s, path=%s, pattern=%s, jsonOutput=%v, labelFilter=%s", repo, path, pattern, jsonOutput, labelFilter) |
| 86 | |
| 87 | var mdFiles []string |
| 88 | var err error |
| 89 | var isRemote bool |
| 90 | |
| 91 | if repo != "" { |
| 92 | // List workflows from remote repository |
| 93 | isRemote = true |
| 94 | if verbose && !jsonOutput { |
| 95 | fmt.Fprintf(os.Stderr, "Listing workflow files from %s\n", repo) |
| 96 | } |
| 97 | mdFiles, err = getRemoteWorkflowFiles(repo, path, verbose, jsonOutput) |
| 98 | } else { |
| 99 | // List workflows from local repository |
| 100 | if verbose && !jsonOutput { |
| 101 | fmt.Fprintf(os.Stderr, "Listing workflow files\n") |
| 102 | if pattern != "" { |
| 103 | fmt.Fprintf(os.Stderr, "Filtering by pattern: %s\n", pattern) |
| 104 | } |
| 105 | } |
| 106 | mdFiles, err = getMarkdownWorkflowFiles(path) |
| 107 | } |
| 108 | |
| 109 | if err != nil { |
| 110 | listWorkflowsLog.Printf("Failed to get markdown workflow files: %v", err) |
| 111 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error())) |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | listWorkflowsLog.Printf("Found %d markdown workflow files", len(mdFiles)) |
| 116 | if len(mdFiles) == 0 { |
| 117 | if jsonOutput { |
| 118 | // Output empty array for JSON |
| 119 | output := []WorkflowListItem{} |
| 120 | jsonBytes, _ := json.MarshalIndent(output, "", " ") |
| 121 | fmt.Fprintln(os.Stdout, string(jsonBytes)) |
| 122 | return nil |
| 123 | } |
| 124 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No workflow files found.")) |
| 125 | return nil |
| 126 | } |
| 127 | |
| 128 | if verbose && !jsonOutput { |
| 129 | fmt.Fprintf(os.Stderr, "Found %d markdown workflow files\n", len(mdFiles)) |
| 130 | } |
| 131 | |
| 132 | // Build workflow list |
| 133 | var workflows []WorkflowListItem |
| 134 | |
| 135 | // Shared import cache across all iterations to avoid re-creating it for every workflow |
| 136 | importCache := parser.NewImportCache("") |
| 137 | |
| 138 | for _, file := range mdFiles { |
| 139 | name := extractWorkflowNameFromPath(file) |
| 140 | |
| 141 | // Skip if pattern specified and doesn't match |