Fixed project / alias autocomplete functions

This commit is contained in:
2023-12-20 11:23:11 -05:00
parent 2082287bdd
commit f5201e8fea
4 changed files with 17 additions and 13 deletions

View File

@ -15,8 +15,7 @@ var projectOpenCmd = &cobra.Command{
Use: "open [fuzzy alias search]",
Short: "Open project in your IDE",
Aliases: []string{"goto", "cd"},
Args: cobra.MaximumNArgs(1),
ArgAliases: []string{"project"},
Args: cobra.OnlyValidArgs,
ValidArgsFunction: validAliasesFunc,
Long: projOpenCmdLong,
Run: projectOpenCmdRun,

View File

@ -4,12 +4,13 @@ import "github.com/spf13/cobra"
func validProjectsFunc(cmd *cobra.Command, args []string, toComplete string) (
[]string, cobra.ShellCompDirective) {
return cache.ProjectStrings(), cobra.ShellCompDirectiveDefault
return cache.ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
}
func validAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
[]string, cobra.ShellCompDirective) {
return cache.AliasStrings(), cobra.ShellCompDirectiveDefault
initProjectCache(cmd, args)
return cache.AliasStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
}
func validProjectsOrAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (