List returns `list` command
(cfg storage, v vcs)
| 8 | |
| 9 | // List returns `list` command |
| 10 | func List(cfg storage, v vcs) *cobra.Command { |
| 11 | return &cobra.Command{ |
| 12 | Use: "list", |
| 13 | Aliases: []string{"l"}, |
| 14 | Short: "List profiles", |
| 15 | Long: "Display the list of available profiles.", |
| 16 | Example: "git-profile list", |
| 17 | Run: func(cmd *cobra.Command, _ []string) { |
| 18 | check(cmd, cfg, v) |
| 19 | |
| 20 | ui.Println(cmd, ui.InfoStyle, "Available profiles:") |
| 21 | |
| 22 | for _, name := range cfg.Names() { |
| 23 | ui.Println(cmd, ui.SuccessStyle, "- %s:", name) |
| 24 | |
| 25 | profile, _ := cfg.Lookup(name) |
| 26 | for _, entry := range profile { |
| 27 | ui.Println(cmd, ui.DefaultStyle, " %s: %s", entry.Key, entry.Value) |
| 28 | } |
| 29 | } |
| 30 | }, |
| 31 | } |
| 32 | } |