Package subcommand code
This commit is contained in:
@ -8,31 +8,34 @@ import (
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func (u *Utils) ValidProjectsFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
func ValidProjectsFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
u := MustFromCtx(cmd.Context())
|
||||
u.InitProjectCache(cmd, args)
|
||||
return u.Cache().ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func (u *Utils) ValidAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
func ValidAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
u.InitProjectCache(cmd, args)
|
||||
return u.Cache().AliasStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
utils := MustFromCtx(cmd.Context())
|
||||
utils.InitProjectCache(cmd, args)
|
||||
return utils.Cache().AliasStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func (u *Utils) ValidProjectsOrAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
projectStrings, _ := u.ValidAliasesFunc(cmd, args, toComplete)
|
||||
aliasStrings, _ := u.ValidProjectsFunc(cmd, args, toComplete)
|
||||
projectStrings, _ := ValidAliasesFunc(cmd, args, toComplete)
|
||||
aliasStrings, _ := ValidProjectsFunc(cmd, args, toComplete)
|
||||
return append(projectStrings, aliasStrings...), cobra.ShellCompDirectiveDefault
|
||||
}
|
||||
|
||||
func (u *Utils) ValidRemotesFunc(_ *cobra.Command, _ []string, toComplete string) (
|
||||
func ValidRemotesFunc(cmd *cobra.Command, _ []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
u := MustFromCtx(cmd.Context())
|
||||
remotes := make([]string, 0, len(u.Config().Remotes))
|
||||
for _, remote := range u.Config().Remotes {
|
||||
if strings.HasPrefix(remote.Host, toComplete) {
|
||||
|
Reference in New Issue
Block a user