feat(config): add config list subcommand
This commit is contained in:
parent
e4a5e7f715
commit
cc19ee5c0f
2 changed files with 29 additions and 0 deletions
|
|
@ -11,6 +11,22 @@ var configCmd = &cobra.Command{
|
||||||
Short: "View and modify configuration",
|
Short: "View and modify configuration",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var configListCmd = &cobra.Command{
|
||||||
|
Use: "list",
|
||||||
|
Aliases: []string{"ls"},
|
||||||
|
Short: "List all configuration values",
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
SilenceUsage: true,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
defaults := defaultConfig()
|
||||||
|
fields := configFields(&config, &defaults)
|
||||||
|
for _, f := range fields {
|
||||||
|
fmt.Printf("%s = %v\n", f.Key, f.Value)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
var configPathCmd = &cobra.Command{
|
var configPathCmd = &cobra.Command{
|
||||||
Use: "path",
|
Use: "path",
|
||||||
Short: "Print config file path",
|
Short: "Print config file path",
|
||||||
|
|
@ -27,6 +43,7 @@ var configPathCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
configCmd.AddCommand(configListCmd)
|
||||||
configCmd.AddCommand(configPathCmd)
|
configCmd.AddCommand(configPathCmd)
|
||||||
rootCmd.AddCommand(configCmd)
|
rootCmd.AddCommand(configCmd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
testdata/config-list.ct
vendored
Normal file
12
testdata/config-list.ct
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
$ pda config list
|
||||||
|
display_ascii_art = true
|
||||||
|
key.always_prompt_delete = false
|
||||||
|
key.always_prompt_glob_delete = true
|
||||||
|
key.always_prompt_overwrite = false
|
||||||
|
store.default_store_name = default
|
||||||
|
store.list_all_stores = true
|
||||||
|
store.always_prompt_delete = true
|
||||||
|
store.always_prompt_overwrite = true
|
||||||
|
git.auto_fetch = false
|
||||||
|
git.auto_commit = false
|
||||||
|
git.auto_push = false
|
||||||
Loading…
Add table
Add a link
Reference in a new issue