Skip to content

Commit

Permalink
Cleanup active command
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Jul 14, 2019
1 parent 3021eec commit 3ded820
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmd/dots/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"github.com/fatih/color"
"github.com/spf13/cobra"

"go.evanpurkhiser.com/dots/config"
Expand Down Expand Up @@ -40,12 +41,18 @@ var configActiveCmd = cobra.Command{
Use: "active",
Short: "Shows the current active profile and groups",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println(sourceLockfile.Profile)
color.New(color.FgHiBlack).Print("profile: ")
if sourceLockfile.Profile == "" {
fmt.Println("<no profile>")
} else {
fmt.Println(sourceLockfile.Profile)
}

color.New(color.FgHiBlack).Print("groups: ")
if groups, ok := sourceConfig.Profiles[sourceLockfile.Profile]; ok {
fmt.Printf(" %s\n", strings.Join(groups, "\n "))
fmt.Printf("[%s]\n", strings.Join(groups, ", "))
} else {
fmt.Printf(" %s\n", strings.Join(sourceLockfile.Groups, "\n "))
fmt.Printf("[%s]\n", strings.Join(sourceLockfile.Groups, ", "))
}

return nil
Expand Down

0 comments on commit 3ded820

Please sign in to comment.