diff options
author | matthieu <matthieu.cneude@gmail.com> | 2021-04-23 13:53:02 +0200 |
---|---|---|
committer | matthieu <matthieu.cneude@gmail.com> | 2021-04-23 13:53:02 +0200 |
commit | 05042039477791ce56b48b309a368e34d2fd4b70 (patch) | |
tree | d3a663ae5a1a8db9ea0624a9e475c22534e4cf89 | |
parent | 2f92e8cf70f32873b7c77d45e9ae82b4b5ab6226 (diff) |
Add possibility to display file extension when listing dashboard config
-rw-r--r-- | cmd/list.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cmd/list.go b/cmd/list.go index fcb9015..61b8398 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -13,6 +13,8 @@ import ( "github.com/spf13/cobra" ) +var extension bool + func listCmd() *cobra.Command { listCmd := &cobra.Command{ Use: "list", @@ -23,6 +25,8 @@ func listCmd() *cobra.Command { }, } + listCmd.Flags().BoolVarP(&extension, "extension", "e", false, "Display file extensions") + return listCmd } @@ -68,9 +72,13 @@ func runList() { for _, f := range fs { s := strings.Split(f.Name(), ".") - // TODO erk + // TODO erk to refactor if !f.IsDir() && len(s) > 1 && (s[1] == "json" || s[1] == "toml" || s[1] == "yaml" || s[1] == "yml") { - fmt.Fprintln(os.Stdout, s[0]) + if extension { + fmt.Fprintln(os.Stdout, f.Name()) + } else { + fmt.Fprintln(os.Stdout, s[0]) + } } } } |