Current returns `current` command
(cfg storage, v vcs)
| 13 | |
| 14 | // Current returns `current` command |
| 15 | func Current(cfg storage, v vcs) *cobra.Command { |
| 16 | return &cobra.Command{ |
| 17 | Use: "current", |
| 18 | Aliases: []string{"c"}, |
| 19 | Short: "Show the current profile", |
| 20 | Long: "Show the selected profile for the current repository.", |
| 21 | Example: "git-profile current", |
| 22 | PreRun: func(cmd *cobra.Command, _ []string) { |
| 23 | check(cmd, cfg, v) |
| 24 | }, |
| 25 | Run: func(cmd *cobra.Command, _ []string) { |
| 26 | profile, err := v.Get(currentProfileKey) |
| 27 | if len(profile) == 0 || err != nil { |
| 28 | profile = defaultProfileName |
| 29 | } |
| 30 | |
| 31 | ui.Println(cmd, ui.SuccessStyle, "Current profile: %s", profile) |
| 32 | }, |
| 33 | } |
| 34 | } |