diff --git a/cmd/config_cmd.go b/cmd/config_cmd.go index 802e815..2e1423c 100644 --- a/cmd/config_cmd.go +++ b/cmd/config_cmd.go @@ -11,6 +11,22 @@ var configCmd = &cobra.Command{ 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{ Use: "path", Short: "Print config file path", @@ -27,6 +43,7 @@ var configPathCmd = &cobra.Command{ } func init() { + configCmd.AddCommand(configListCmd) configCmd.AddCommand(configPathCmd) rootCmd.AddCommand(configCmd) } diff --git a/testdata/config-list.ct b/testdata/config-list.ct new file mode 100644 index 0000000..3df2e13 --- /dev/null +++ b/testdata/config-list.ct @@ -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