MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / runCommunityScriptsSearch

Function runCommunityScriptsSearch

internal/cli/community_scripts.go:153–187  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

151}
152
153func 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
189func runCommunityScriptsShow(cmd *cobra.Command, args []string) error {
190 session, err := initCLISession(cmd)

Callers

nothing calls this directly

Calls 7

initCLISessionFunction · 0.85
printErrorFunction · 0.85
communityScriptsToOutputFunction · 0.85
getOutputFormatFunction · 0.85
printTableFunction · 0.85
printJSONFunction · 0.85

Tested by

no test coverage detected