summaryrefslogtreecommitdiffstatshomepage
path: root/commands/user.go
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2021-01-24 14:05:40 +0100
committerMichael Muré <batolettre@gmail.com>2022-05-01 10:54:13 +0200
commitbc6ba02bd84fc3bd86c61e89c16c400dfef01623 (patch)
treed6a88de7569493795544eedeb962a1dc859b8e71 /commands/user.go
parent8ee333582ff82d0df971309e94946f2f6e69475b (diff)
downloadgit-bug-bc6ba02bd84fc3bd86c61e89c16c400dfef01623.tar.gz
git-bug-bc6ba02bd84fc3bd86c61e89c16c400dfef01623.zip
Add command-specific argument completions
Complete bug IDs, bridges, users, labels where appropriate. This works in bash and fish. ZSH is not yet supported by Cobra. In fish, descriptions (the part of a completion after the "\t") are shown as completion label, and can be searched with Ctrl+S. Reproduce with fish -C 'source misc/fish_completion/git-bug' git bug select ^I (tested with fish version 3.3.1) Also works with bash, but only for "git-bug" (with the dash) bash --rcfile <(echo source misc/bash_completion/git-bug) git-bug select ^I Closes #493
Diffstat (limited to 'commands/user.go')
-rw-r--r--commands/user.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/commands/user.go b/commands/user.go
index b6a2e485..0fe3be4d 100644
--- a/commands/user.go
+++ b/commands/user.go
@@ -3,6 +3,7 @@ package commands
import (
"errors"
"fmt"
+ "strings"
"github.com/spf13/cobra"
@@ -24,6 +25,7 @@ func newUserCommand() *cobra.Command {
RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
return runUser(env, options, args)
}),
+ ValidArgsFunction: completeUser(env),
}
cmd.AddCommand(newUserAdoptCommand())
@@ -33,8 +35,10 @@ func newUserCommand() *cobra.Command {
flags := cmd.Flags()
flags.SortFlags = false
+ fields := []string{"email", "humanId", "id", "lastModification", "lastModificationLamports", "login", "metadata", "name"}
flags.StringVarP(&options.fields, "field", "f", "",
- "Select field to display. Valid values are [email,humanId,id,lastModification,lastModificationLamports,login,metadata,name]")
+ "Select field to display. Valid values are ["+strings.Join(fields, ",")+"]")
+ cmd.RegisterFlagCompletionFunc("field", completeFrom(fields))
return cmd
}