feat(config): add config list subcommand

This commit is contained in:
Lewis Wynne 2026-02-11 23:35:51 +00:00
parent e4a5e7f715
commit cc19ee5c0f
2 changed files with 29 additions and 0 deletions

View file

@ -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)
}

12
testdata/config-list.ct vendored Normal file
View 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