diff --git a/cli/cli.go b/cli/cli.go index 1066fb77..56f253f6 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -14,6 +14,7 @@ import ( "coopcloud.tech/abra/cli/recipe" "coopcloud.tech/abra/cli/record" "coopcloud.tech/abra/cli/server" + "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/config" "coopcloud.tech/abra/pkg/web" "github.com/sirupsen/logrus" @@ -162,6 +163,7 @@ func newAbraApp(version, commit string) *cli.App { UpgradeCommand, AutoCompleteCommand, }, + BashComplete: autocomplete.SubcommandComplete, Authors: []cli.Author{ // If you're looking at this and you hack on Abra and you're not listed // here, please do add yourself! This is a community project, let's show diff --git a/pkg/autocomplete/autocomplete.go b/pkg/autocomplete/autocomplete.go index 8e24adca..e295afa7 100644 --- a/pkg/autocomplete/autocomplete.go +++ b/pkg/autocomplete/autocomplete.go @@ -40,3 +40,24 @@ func RecipeNameComplete(c *cli.Context) { fmt.Println(name) } } + +// SubcommandComplete completes subcommands. +func SubcommandComplete(c *cli.Context) { + if c.NArg() > 0 { + return + } + + subcmds := []string{ + "app", + "autocomplete", + "catalogue", + "recipe", + "record", + "server", + "upgrade", + } + + for _, cmd := range subcmds { + fmt.Println(cmd) + } +}