1package commands
2
3import (
4 "fmt"
5
6 "github.com/MichaelMure/git-bug/cache"
7 "github.com/MichaelMure/git-bug/util/colors"
8 "github.com/MichaelMure/git-bug/util/interrupt"
9 "github.com/spf13/cobra"
10)
11
12func runUserLs(cmd *cobra.Command, args []string) error {
13 backend, err := cache.NewRepoCache(repo)
14 if err != nil {
15 return err
16 }
17 defer backend.Close()
18 interrupt.RegisterCleaner(backend.Close)
19
20 for _, i := range backend.AllIdentityExcerpt() {
21 fmt.Printf("%s %s\n",
22 colors.Cyan(i.HumanId()),
23 i.DisplayName(),
24 )
25 }
26
27 return nil
28}
29
30var userLsCmd = &cobra.Command{
31 Use: "ls",
32 Short: "List identities.",
33 PreRunE: loadRepo,
34 RunE: runUserLs,
35}
36
37func init() {
38 userCmd.AddCommand(userLsCmd)
39 userLsCmd.Flags().SortFlags = false
40}