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

Function completeCommunityScriptSlugs

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

Source from the content-addressed store, hash-verified

638}
639
640func completeCommunityScriptSlugs(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
641 if len(args) != 0 {
642 return nil, cobra.ShellCompDirectiveNoFileComp
643 }
644
645 session, err := initCLISession(cmd)
646 if err != nil || session == nil || ensureCommunityScriptsEnabled(session) != nil {
647 return nil, cobra.ShellCompDirectiveNoFileComp
648 }
649
650 scripts, err := core.FetchScripts()
651 if err != nil {
652 return nil, cobra.ShellCompDirectiveNoFileComp
653 }
654
655 prefix := strings.ToLower(toComplete)
656 completions := make([]string, 0, len(scripts))
657 for _, script := range scripts {
658 if prefix == "" || strings.HasPrefix(strings.ToLower(script.Slug), prefix) {
659 completions = append(completions, fmt.Sprintf("%s\t%s", script.Slug, script.Name))
660 }
661 }
662
663 return completions, cobra.ShellCompDirectiveNoFileComp
664}

Callers

nothing calls this directly

Calls 2

initCLISessionFunction · 0.85

Tested by

no test coverage detected