mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Add --keys flag to config list command to show only config keys
This commit is contained in:
parent
1ca444a79d
commit
3d475143c1
@ -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.
|
||||
|
@ -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="" \
|
||||
|
@ -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"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user