(cmd *cobra.Command, args []string)
| 151 | } |
| 152 | |
| 153 | func runCommunityScriptsSearch(cmd *cobra.Command, args []string) error { |
| 154 | session, err := initCLISession(cmd) |
| 155 | if err != nil { |
| 156 | return printError(err) |
| 157 | } |
| 158 | if session == nil { |
| 159 | return nil |
| 160 | } |
| 161 | if err := ensureCommunityScriptsEnabled(session); err != nil { |
| 162 | return printError(err) |
| 163 | } |
| 164 | |
| 165 | scripts, err := core.FetchScripts() |
| 166 | if err != nil { |
| 167 | return printError(fmt.Errorf("failed to fetch community scripts: %w", err)) |
| 168 | } |
| 169 | |
| 170 | matches := core.SearchScripts(scripts, args[0]) |
| 171 | out := communityScriptsToOutput(matches) |
| 172 | |
| 173 | if getOutputFormat(cmd) == outputTable { |
| 174 | rows := make([][]string, 0, len(out)) |
| 175 | for _, script := range out { |
| 176 | state := "prod" |
| 177 | if script.IsDev { |
| 178 | state = "dev" |
| 179 | } |
| 180 | rows = append(rows, []string{script.Name, script.Slug, script.Type, state, script.Description}) |
| 181 | } |
| 182 | printTable([]string{"NAME", "SLUG", "TYPE", "SOURCE", "DESCRIPTION"}, rows) |
| 183 | return nil |
| 184 | } |
| 185 | |
| 186 | return printJSON(out) |
| 187 | } |
| 188 | |
| 189 | func runCommunityScriptsShow(cmd *cobra.Command, args []string) error { |
| 190 | session, err := initCLISession(cmd) |
nothing calls this directly
no test coverage detected