MCPcopy Index your code
hub / github.com/cli/cli / RegisterBranchCompletionFlags

Function RegisterBranchCompletionFlags

pkg/cmdutil/flags.go:53–66  ·  view source on GitHub ↗

RegisterBranchCompletionFlags suggests and autocompletes known remote git branches for flags passed

(gitc gitClient, cmd *cobra.Command, flags ...string)

Source from the content-addressed store, hash-verified

51
52// RegisterBranchCompletionFlags suggests and autocompletes known remote git branches for flags passed
53func RegisterBranchCompletionFlags(gitc gitClient, cmd *cobra.Command, flags ...string) error {
54 for _, flag := range flags {
55 err := cmd.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
56 if repoFlag := cmd.Flag("repo"); repoFlag != nil && repoFlag.Changed {
57 return nil, cobra.ShellCompDirectiveNoFileComp
58 }
59 return gitc.TrackingBranchNames(context.TODO(), toComplete), cobra.ShellCompDirectiveNoFileComp
60 })
61 if err != nil {
62 return err
63 }
64 }
65 return nil
66}
67
68func formatValuesForUsageDocs(values []string) string {
69 return fmt.Sprintf("{%s}", strings.Join(values, "|"))

Callers 11

NewCmdCreateFunction · 0.92
NewCmdEditFunction · 0.92
NewCmdPrsFunction · 0.92
NewCmdBrowseFunction · 0.92
NewCmdViewFunction · 0.92
NewCmdListFunction · 0.92
NewCmdListFunction · 0.92
NewCmdCreateFunction · 0.92
NewCmdEditFunction · 0.92
NewCmdViewFunction · 0.92
NewCmdRunFunction · 0.92

Calls 1

TrackingBranchNamesMethod · 0.65

Tested by

no test coverage detected