feat(config): some additional config options, and config migration from deprecated keys

This commit is contained in:
Lewis Wynne 2026-02-12 19:31:24 +00:00
parent 629358a81b
commit 4e78cefd56
16 changed files with 363 additions and 51 deletions

View file

@ -1,10 +1,30 @@
# Init creates a config file
$ pda config init
ok generated config: /tmp/TestMain2533282848/002/config.toml
# Second init fails
$ pda config init --> FAIL
FAIL config file already exists
hint use 'pda config edit' or 'pda config init --new'
hint use '--update' to update your config, or '--new' to get a fresh copy
# Init --new overwrites
$ pda config init --new
ok generated config: /tmp/TestMain2533282848/002/config.toml
# --update preserves user changes
$ pda config set list.always_show_all_stores false
$ pda config get list.always_show_all_stores
ok list.always_show_all_stores set to 'false'
false
$ pda config init --update
$ pda config get list.always_show_all_stores
ok updated config: /tmp/TestMain2533282848/002/config.toml
false
# --new and --update are mutually exclusive
$ pda config init --new --update --> FAIL
FAIL --new and --update are mutually exclusive
# Reset for other tests
$ pda config init --new
ok generated config: /tmp/TestMain2533282848/002/config.toml

View file

@ -3,11 +3,16 @@ display_ascii_art = true
key.always_prompt_delete = false
key.always_prompt_glob_delete = true
key.always_prompt_overwrite = false
key.always_encrypt = false
store.default_store_name = default
store.always_prompt_delete = true
store.always_prompt_overwrite = true
list.list_all_stores = true
list.always_show_all_stores = true
list.default_list_format = table
list.always_show_full_values = false
list.always_hide_header = false
list.default_columns = key,store,value,ttl
git.auto_fetch = false
git.auto_commit = false
git.auto_push = false
git.default_commit_message = sync: {{.Time}}

View file

@ -1,16 +1,19 @@
# Set a bool value and verify with get
$ pda config set git.auto_commit true
$ pda config get git.auto_commit
ok git.auto_commit set to 'true'
true
# Set a string value
$ pda config set store.default_store_name mystore
$ pda config get store.default_store_name
ok store.default_store_name set to 'mystore'
mystore
# Set back to original
$ pda config set git.auto_commit false
$ pda config get git.auto_commit
ok git.auto_commit set to 'false'
false
# Bad type
@ -24,9 +27,32 @@ FAIL cannot set 'list.default_list_format': must be one of 'table', 'tsv', 'csv'
# Valid list format
$ pda config set list.default_list_format json
$ pda config get list.default_list_format
ok list.default_list_format set to 'json'
json
# Invalid list columns
$ pda config set list.default_columns foo --> FAIL
FAIL cannot set 'list.default_columns': must be a comma-separated list of 'key', 'store', 'value', 'ttl' (got 'foo')
# Duplicate columns
$ pda config set list.default_columns key,key --> FAIL
FAIL cannot set 'list.default_columns': duplicate column 'key'
# Valid list columns
$ pda config set list.default_columns key,value
$ pda config get list.default_columns
ok list.default_columns set to 'key,value'
key,value
# Unknown key
$ pda config set git.auto_comit true --> FAIL
FAIL unknown config key 'git.auto_comit'
hint did you mean 'git.auto_commit'?
# Reset changed values so subsequent tests see defaults
$ pda config set store.default_store_name default
$ pda config set list.default_list_format table
$ pda config set list.default_columns key,store,value,ttl
ok store.default_store_name set to 'default'
ok list.default_list_format set to 'table'
ok list.default_columns set to 'key,store,value,ttl'

11
testdata/list-config-columns.ct vendored Normal file
View file

@ -0,0 +1,11 @@
# default_columns = "key,value" shows only key and value
$ pda config set list.default_columns key,value
$ pda set a@lcc 1
$ pda ls lcc --format tsv
ok list.default_columns set to 'key,value'
Key Value
a 1
# Reset
$ pda config set list.default_columns key,store,value,ttl
ok list.default_columns set to 'key,store,value,ttl'

10
testdata/list-config-hide-header.ct vendored Normal file
View file

@ -0,0 +1,10 @@
# always_hide_header config suppresses the header row
$ pda config set list.always_hide_header true
$ pda set a@lchh 1
$ pda ls lchh --format tsv
ok list.always_hide_header set to 'true'
a lchh 1 no expiry
# Reset
$ pda config set list.always_hide_header false
ok list.always_hide_header set to 'false'

10
testdata/set-config-encrypt.ct vendored Normal file
View file

@ -0,0 +1,10 @@
# always_encrypt config encrypts without --encrypt flag
$ pda config set key.always_encrypt true
$ pda set secret-key@sce mysecretvalue
$ pda get secret-key@sce
ok key.always_encrypt set to 'true'
mysecretvalue
# Reset
$ pda config set key.always_encrypt false
ok key.always_encrypt set to 'false'