mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
commands: add a --field flag to "git bug user" to display users details individually
This commit is contained in:
parent
96d356a34d
commit
5b0a92dea4
@ -9,6 +9,10 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
userFieldsQuery string
|
||||||
|
)
|
||||||
|
|
||||||
func runUser(cmd *cobra.Command, args []string) error {
|
func runUser(cmd *cobra.Command, args []string) error {
|
||||||
backend, err := cache.NewRepoCache(repo)
|
backend, err := cache.NewRepoCache(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -32,6 +36,35 @@ func runUser(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if userFieldsQuery != "" {
|
||||||
|
switch userFieldsQuery {
|
||||||
|
case "email":
|
||||||
|
fmt.Printf("%s\n", id.Email())
|
||||||
|
case "humanId":
|
||||||
|
fmt.Printf("%s\n", id.HumanId())
|
||||||
|
case "id":
|
||||||
|
fmt.Printf("%s\n", id.Id())
|
||||||
|
case "lastModification":
|
||||||
|
fmt.Printf("%s\n", id.LastModification().
|
||||||
|
Time().Format("Mon Jan 2 15:04:05 2006 +0200"))
|
||||||
|
case "lastModificationLamport":
|
||||||
|
fmt.Printf("%d\n", id.LastModificationLamport())
|
||||||
|
case "login":
|
||||||
|
fmt.Printf("%s\n", id.Login())
|
||||||
|
case "metadata":
|
||||||
|
for key, value := range id.ImmutableMetadata() {
|
||||||
|
fmt.Printf("%s\n%s\n", key, value)
|
||||||
|
}
|
||||||
|
case "name":
|
||||||
|
fmt.Printf("%s\n", id.Name())
|
||||||
|
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("\nUnsupported field: %s\n", userFieldsQuery)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("Id: %s\n", id.Id())
|
fmt.Printf("Id: %s\n", id.Id())
|
||||||
fmt.Printf("Name: %s\n", id.Name())
|
fmt.Printf("Name: %s\n", id.Name())
|
||||||
fmt.Printf("Login: %s\n", id.Login())
|
fmt.Printf("Login: %s\n", id.Login())
|
||||||
@ -58,4 +91,7 @@ var userCmd = &cobra.Command{
|
|||||||
func init() {
|
func init() {
|
||||||
RootCmd.AddCommand(userCmd)
|
RootCmd.AddCommand(userCmd)
|
||||||
userCmd.Flags().SortFlags = false
|
userCmd.Flags().SortFlags = false
|
||||||
|
|
||||||
|
userCmd.Flags().StringVarP(&userFieldsQuery, "field", "f", "",
|
||||||
|
"Select field to display. Valid values are [email,humanId,id,lastModification,lastModificationLamport,login,metadata,name]")
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,10 @@ Display or change the user identity.
|
|||||||
|
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
|
.PP
|
||||||
|
\fB\-f\fP, \fB\-\-field\fP=""
|
||||||
|
Select field to display. Valid values are [email,humanId,id,lastModification,lastModificationLamport,login,metadata,name]
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-h\fP, \fB\-\-help\fP[=false]
|
\fB\-h\fP, \fB\-\-help\fP[=false]
|
||||||
help for user
|
help for user
|
||||||
|
@ -13,7 +13,8 @@ git-bug user [<user-id>] [flags]
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
-h, --help help for user
|
-f, --field string Select field to display. Valid values are [email,humanId,id,lastModification,lastModificationLamport,login,metadata,name]
|
||||||
|
-h, --help help for user
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
@ -879,6 +879,9 @@ _git-bug_user()
|
|||||||
flags_with_completion=()
|
flags_with_completion=()
|
||||||
flags_completion=()
|
flags_completion=()
|
||||||
|
|
||||||
|
flags+=("--field=")
|
||||||
|
two_word_flags+=("-f")
|
||||||
|
local_nonpersistent_flags+=("--field=")
|
||||||
|
|
||||||
must_have_one_flag=()
|
must_have_one_flag=()
|
||||||
must_have_one_noun=()
|
must_have_one_noun=()
|
||||||
|
Loading…
Reference in New Issue
Block a user