From 3d475143c17e59ab16d1e6a2df56117190c131a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Mej=C3=ADas=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 20:34:22 -0400 Subject: [PATCH] Add --keys flag to config list command to show only config keys --- CHANGELOG.md | 1 + Dockerfile | 1 + cmd/configList.go | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5090231..0c37062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - `config` command to get and set configuration options. - `config list|ls` command to list configuration options. + - `--keys` flag to show only config keys. - `endpoint list|ls` command to print the endpoints list as a table. - `--format` flag to format output using a Go template. - `stack list|ls` command to print the stacks list as a table. diff --git a/Dockerfile b/Dockerfile index 6cee044..990d3b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM alpine ENV PSU_AUTHENTICATION_PASSWORD="" \ PSU_AUTHENTICATION_USER="" \ PSU_CONFIG="" \ + PSU_CONFIG_LIST_KEYS="" \ PSU_CONNECTION_INSECURE="" \ PSU_CONNECTION_TIMEOUT="" \ PSU_CONNECTION_URL="" \ diff --git a/cmd/configList.go b/cmd/configList.go index 08bef2e..814f3d7 100644 --- a/cmd/configList.go +++ b/cmd/configList.go @@ -20,13 +20,21 @@ var configListCmd = &cobra.Command{ return keys[i] < keys[j] }) - // List keys and values for _, key := range keys { - fmt.Printf("%s: %v\n", key, viper.Get(key)) + if viper.GetBool("config.list.keys") { + // List config key + fmt.Println(key) + } else { + // List config key and value + fmt.Printf("%s: %v\n", key, viper.Get(key)) + } } }, } func init() { configCmd.AddCommand(configListCmd) + + configListCmd.Flags().Bool("keys", false, "list only keys") + viper.BindPFlag("config.list.keys", configListCmd.Flags().Lookup("keys")) }