Skip to content

Commit

Permalink
add listThemes()
Browse files Browse the repository at this point in the history
  • Loading branch information
koki-develop committed Apr 15, 2023
1 parent 39d1260 commit 2660ff4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"os"
"strings"

"github.com/spf13/cobra"
)
Expand All @@ -20,11 +21,7 @@ var rootCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
t, ok := themes[flagTheme]
if !ok {
valid := []string{}
for k := range themes {
valid = append(valid, k)
}
return fmt.Errorf("valid themes: %s", valid)
return fmt.Errorf("valid themes: %s", listThemes())
}

cal, err := fetchCalendar(flagUser)
Expand All @@ -51,5 +48,5 @@ func init() {
rootCmd.Flags().SortFlags = false

rootCmd.Flags().StringVarP(&flagUser, "user", "u", "", "github username")
rootCmd.Flags().StringVarP(&flagTheme, "theme", "t", "dark", "grass theme (dark|light)")
rootCmd.Flags().StringVarP(&flagTheme, "theme", "t", "dark", fmt.Sprintf("grass theme (%s)", strings.Join(listThemes(), "|")))
}
10 changes: 10 additions & 0 deletions cmd/themes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ var themes = map[string]theme{
contributionLevelFourthQuartile: "#216E39",
},
}

func listThemes() []string {
ts := []string{}

for t := range themes {
ts = append(ts, t)
}

return ts
}

0 comments on commit 2660ff4

Please sign in to comment.