refactor(msg): single space between keyword and message, improve config suggestions

Tightens keyword formatting (ok/FAIL/hint/etc.) from two spaces to one.
Makes config key suggestions more generous: normalises spaces to
underscores, matches against leaf segments, and uses substring matching.
Updates all golden files.
This commit is contained in:
Lewis Wynne 2026-02-11 23:47:59 +00:00
parent db607ac696
commit c9b448d508
47 changed files with 144 additions and 118 deletions

View file

@ -7,7 +7,12 @@ default
$ pda config get git.auto_commit
false
# Unknown key with suggestion
# Unknown key with suggestion (typo)
$ pda config get git.auto_comit --> FAIL
FAIL unknown config key 'git.auto_comit'
hint did you mean 'git.auto_commit'?
FAIL unknown config key 'git.auto_comit'
hint did you mean 'git.auto_commit'?
# Unknown key with suggestion (leaf match, no prefix)
$ pda config get auto_commit --> FAIL
FAIL unknown config key 'auto_commit'
hint did you mean 'git.auto_commit'?

View file

@ -3,8 +3,8 @@ $ pda config init
# Second init fails
$ pda config init --> FAIL
FAIL config file already exists
hint use 'pda config edit' or 'pda config init --new'
FAIL config file already exists
hint use 'pda config edit' or 'pda config init --new'
# Init --new overwrites
$ pda config init --new

View file

@ -1,7 +1,7 @@
# Cross-store copy
$ pda set key@src value
$ pda cp key@src key@dst
ok copied key@src to key@dst
ok copied key@src to key@dst
$ pda get key@src
value
$ pda get key@dst

View file

@ -1,7 +1,7 @@
# Copy an encrypted key; both keys should decrypt.
$ pda set --encrypt secret-key@cpe hidden-value
$ pda cp secret-key@cpe copied-key@cpe
ok copied secret-key@cpe to copied-key@cpe
ok copied secret-key@cpe to copied-key@cpe
$ pda get secret-key@cpe
hidden-value
$ pda get copied-key@cpe

View file

@ -1,3 +1,3 @@
# Copy non-existent key
$ pda cp nonexistent dest --> FAIL
FAIL cannot move 'nonexistent': no such key
FAIL cannot move 'nonexistent': no such key

2
testdata/cp-safe.ct vendored
View file

@ -1,6 +1,6 @@
$ pda set src@csf hello
$ pda set dst@csf existing
$ pda cp src@csf dst@csf --safe
info skipped 'dst@csf': already exists
info skipped 'dst@csf': already exists
$ pda get dst@csf
existing

2
testdata/cp.ct vendored
View file

@ -1,7 +1,7 @@
# Basic copy
$ pda set source@cpok value
$ pda cp source@cpok dest@cpok
ok copied source@cpok to dest@cpok
ok copied source@cpok to dest@cpok
$ pda get source@cpok
value
$ pda get dest@cpok

View file

@ -5,4 +5,4 @@ $ pda export ekf --key "a*"
{"key":"a1","value":"1","encoding":"text","store":"ekf"}
{"key":"a2","value":"2","encoding":"text","store":"ekf"}
$ pda export ekf --key "c*" --> FAIL
FAIL cannot ls '@ekf': no matches for key pattern 'c*'
FAIL cannot ls '@ekf': no matches for key pattern 'c*'

View file

@ -1,2 +1,2 @@
$ pda get key@foo/bar --> FAIL
FAIL cannot get 'key@foo/bar': bad store format, use STORE or @STORE
FAIL cannot get 'key@foo/bar': bad store format, use STORE or @STORE

View file

@ -5,10 +5,10 @@ $ pda get foobar --base64 --run --secret --> FAIL
$ pda get foobar --run --> FAIL
$ pda get foobar --run --secret --> FAIL
$ pda get foobar --secret --> FAIL
FAIL cannot get 'foobar': no such key
FAIL cannot get 'foobar': no such key
FAIL cannot get 'foobar': no such key
FAIL unknown flag: --secret
FAIL cannot get 'foobar': no such key
FAIL unknown flag: --secret
FAIL unknown flag: --secret
FAIL cannot get 'foobar': no such key
FAIL cannot get 'foobar': no such key
FAIL cannot get 'foobar': no such key
FAIL unknown flag: --secret
FAIL cannot get 'foobar': no such key
FAIL unknown flag: --secret
FAIL unknown flag: --secret

View file

@ -1,2 +1,2 @@
$ pda get foobar --> FAIL
FAIL cannot get 'foobar': no such key
FAIL cannot get 'foobar': no such key

View file

@ -2,8 +2,8 @@ $ pda set existing@idr keep-me
$ pda set other@idr also-keep
$ fecho dumpfile {"key":"new","value":"hello","encoding":"text"}
$ pda import idr --drop --file dumpfile
ok restored 1 entries into @idr
ok restored 1 entries into @idr
$ pda get new@idr
hello
$ pda get existing@idr --> FAIL
FAIL cannot get 'existing@idr': no such key
FAIL cannot get 'existing@idr': no such key

View file

@ -4,13 +4,13 @@ $ pda set b1@ikf 3
$ fecho dumpfile {"key":"a1","value":"1","encoding":"text"} {"key":"a2","value":"2","encoding":"text"} {"key":"b1","value":"3","encoding":"text"}
$ pda rm a1@ikf a2@ikf b1@ikf
$ pda import ikf --key "a*" --file dumpfile
ok restored 2 entries into @ikf
ok restored 2 entries into @ikf
$ pda get a1@ikf
1
$ pda get a2@ikf
2
$ pda get b1@ikf --> FAIL
FAIL cannot get 'b1@ikf': no such key
hint did you mean 'a1'?
FAIL cannot get 'b1@ikf': no such key
hint did you mean 'a1'?
$ pda import ikf --key "c*" --file dumpfile --> FAIL
FAIL cannot restore '@ikf': no matches for key pattern 'c*'
FAIL cannot restore '@ikf': no matches for key pattern 'c*'

View file

@ -2,7 +2,7 @@
$ pda set existing@mrg old-value
$ fecho dumpfile {"key":"existing","value":"updated","encoding":"text"} {"key":"new","value":"hello","encoding":"text"}
$ pda import mrg --file dumpfile
ok restored 2 entries into @mrg
ok restored 2 entries into @mrg
$ pda get existing@mrg
updated
$ pda get new@mrg

View file

@ -2,7 +2,7 @@
$ pda set existing@stn keep-me
$ fecho dumpfile {"key":"new","value":"hello","encoding":"text"}
$ pda import stn < dumpfile
ok restored 1 entries into @stn
ok restored 1 entries into @stn
$ pda get existing@stn
keep-me
$ pda get new@stn

View file

@ -1,2 +1,2 @@
$ pda invalidcmd --> FAIL
FAIL unknown command "invalidcmd" for "pda"
FAIL unknown command "invalidcmd" for "pda"

View file

@ -1,5 +1,5 @@
# Error when all columns are suppressed
$ pda set a@las 1
$ pda ls las --no-keys --no-values --no-ttl --> FAIL
FAIL cannot ls '@las': no columns selected
hint disable --no-keys, --no-values, or --no-ttl
FAIL cannot ls '@las': no columns selected
hint disable --no-keys, --no-values, or --no-ttl

View file

@ -23,7 +23,7 @@ Key Store Value TTL
lax laa 1 no expiry
# --store cannot be combined with positional arg
$ pda ls --store "laa" laa --> FAIL
FAIL cannot use --store with a store argument
FAIL cannot use --store with a store argument
# --store no matches
$ pda ls --store "nonexistent" --key "lax" --> FAIL
FAIL cannot ls 'all': no matches for key pattern 'lax' and store pattern 'nonexistent'
FAIL cannot ls 'all': no matches for key pattern 'lax' and store pattern 'nonexistent'

View file

@ -1,2 +1,2 @@
$ pda ls foo/bar --> FAIL
FAIL cannot ls 'foo/bar': cannot parse store: bad store format, use STORE or @STORE
FAIL cannot ls 'foo/bar': cannot parse store: bad store format, use STORE or @STORE

View file

@ -9,4 +9,4 @@ $ pda ls lg --key "b*" --format tsv
Key Store Value TTL
b1 lg 3 no expiry
$ pda ls lg --key "c*" --> FAIL
FAIL cannot ls '@lg': no matches for key pattern 'c*'
FAIL cannot ls '@lg': no matches for key pattern 'c*'

View file

@ -8,4 +8,4 @@ $ pda ls kv -k "*url*" -v "**example**" --format tsv
Key Store Value TTL
apiurl kv https://api.example.com no expiry
$ pda ls kv -k "db*" -v "**nomatch**" --> FAIL
FAIL cannot ls '@kv': no matches for key pattern 'db*' and value pattern '**nomatch**'
FAIL cannot ls '@kv': no matches for key pattern 'db*' and value pattern '**nomatch**'

View file

@ -12,4 +12,4 @@ $ pda ls vt --value "*" --format tsv
Key Store Value TTL
number vt 42 no expiry
$ pda ls vt --value "**nomatch**" --> FAIL
FAIL cannot ls '@vt': no matches for value pattern '**nomatch**'
FAIL cannot ls '@vt': no matches for value pattern '**nomatch**'

View file

@ -1,8 +1,8 @@
# Cross-store move
$ pda set key@src value
$ pda mv key@src key@dst
ok renamed key@src to key@dst
ok renamed key@src to key@dst
$ pda get key@dst
value
$ pda get key@src --> FAIL
FAIL cannot get 'key@src': no such key
FAIL cannot get 'key@src': no such key

View file

@ -1,8 +1,8 @@
# Move an encrypted key; the new key should still decrypt.
$ pda set --encrypt secret-key@mve hidden-value
$ pda mv secret-key@mve moved-key@mve
ok renamed secret-key@mve to moved-key@mve
ok renamed secret-key@mve to moved-key@mve
$ pda get moved-key@mve
hidden-value
$ pda get secret-key@mve --> FAIL
FAIL cannot get 'secret-key@mve': no such key
FAIL cannot get 'secret-key@mve': no such key

View file

@ -1,3 +1,3 @@
# Move non-existent key
$ pda mv nonexistent dest --> FAIL
FAIL cannot move 'nonexistent': no such key
FAIL cannot move 'nonexistent': no such key

2
testdata/mv-safe.ct vendored
View file

@ -1,7 +1,7 @@
$ pda set src@msf hello
$ pda set dst@msf existing
$ pda mv src@msf dst@msf --safe
info skipped 'dst@msf': already exists
info skipped 'dst@msf': already exists
$ pda get src@msf
hello
$ pda get dst@msf

View file

@ -1,6 +1,6 @@
$ pda set key@msc1 value
$ pda move-store msc1 msc2 --copy
ok copied @msc1 to @msc2
ok copied @msc1 to @msc2
$ pda get key@msc1
value
$ pda get key@msc2

View file

@ -1,2 +1,2 @@
$ pda move-store nonexistent dest --> FAIL
FAIL cannot rename store 'nonexistent': no such store
FAIL cannot rename store 'nonexistent': no such store

View file

@ -1,7 +1,7 @@
$ pda set a@mssf1 1
$ pda set b@mssf2 2
$ pda move-store mssf1 mssf2 --safe
info skipped '@mssf2': already exists
info skipped '@mssf2': already exists
$ pda get a@mssf1
1
$ pda get b@mssf2

View file

@ -1,3 +1,3 @@
$ pda set a@mss same
$ pda move-store mss mss --> FAIL
FAIL cannot rename store 'mss': source and destination are the same
FAIL cannot rename store 'mss': source and destination are the same

View file

@ -1,5 +1,5 @@
$ pda set key@mvs1 value
$ pda move-store mvs1 mvs2
ok renamed @mvs1 to @mvs2
ok renamed @mvs1 to @mvs2
$ pda get key@mvs2
value

4
testdata/mv.ct vendored
View file

@ -1,8 +1,8 @@
# Basic move
$ pda set source@mvok value
$ pda mv source@mvok dest@mvok
ok renamed source@mvok to dest@mvok
ok renamed source@mvok to dest@mvok
$ pda get dest@mvok
value
$ pda get source@mvok --> FAIL
FAIL cannot get 'source@mvok': no such key
FAIL cannot get 'source@mvok': no such key

View file

@ -7,6 +7,6 @@ bar rdd 2 no expiry
foo rdd 1 no expiry
$ pda rm foo@rdd --key "*@rdd" -y
$ pda get bar@rdd --> FAIL
FAIL cannot get 'bar@rdd': no such key
FAIL cannot get 'bar@rdd': no such key
$ pda get foo@rdd --> FAIL
FAIL cannot get 'foo@rdd': no such key
FAIL cannot get 'foo@rdd': no such key

View file

@ -3,9 +3,9 @@ $ pda set a2@rkg 2
$ pda set b1@rkg 3
$ pda rm --key "a*@rkg" -y
$ pda get a1@rkg --> FAIL
FAIL cannot get 'a1@rkg': no such key
hint did you mean 'b1'?
FAIL cannot get 'a1@rkg': no such key
hint did you mean 'b1'?
$ pda get a2@rkg --> FAIL
FAIL cannot get 'a2@rkg': no such key
FAIL cannot get 'a2@rkg': no such key
$ pda get b1@rkg
3

View file

@ -3,8 +3,8 @@ $ pda set bar1@rkm 2
$ pda set bar2@rkm 3
$ pda rm foo@rkm --key "bar*@rkm" -y
$ pda get foo@rkm --> FAIL
FAIL cannot get 'foo@rkm': no such key
FAIL cannot get 'foo@rkm': no such key
$ pda get bar1@rkm --> FAIL
FAIL cannot get 'bar1@rkm': no such key
FAIL cannot get 'bar1@rkm': no such key
$ pda get bar2@rkm --> FAIL
FAIL cannot get 'bar2@rkm': no such key
FAIL cannot get 'bar2@rkm': no such key

View file

@ -2,6 +2,6 @@ $ pda set a@rmm 1
$ pda set b@rmm 2
$ pda rm a@rmm b@rmm
$ pda get a@rmm --> FAIL
FAIL cannot get 'a@rmm': no such key
FAIL cannot get 'a@rmm': no such key
$ pda get b@rmm --> FAIL
FAIL cannot get 'b@rmm': no such key
FAIL cannot get 'b@rmm': no such key

View file

@ -1,2 +1,2 @@
$ pda rms foo/bar --> FAIL
FAIL cannot delete store 'foo/bar': cannot parse store: bad store format, use STORE or @STORE
FAIL cannot delete store 'foo/bar': cannot parse store: bad store format, use STORE or @STORE

View file

@ -2,7 +2,7 @@ $ pda set a@ry "1"
$ pda set b@ry "2"
$ pda rm a@ry -i -y
$ pda get a@ry --> FAIL
FAIL cannot get 'a@ry': no such key
hint did you mean 'b'?
FAIL cannot get 'a@ry': no such key
hint did you mean 'b'?
$ pda get b@ry
"2"

View file

@ -1,3 +1,3 @@
$ fecho myfile contents
$ pda set key@sfc value --file myfile --> FAIL
FAIL cannot set 'key@sfc': --file and VALUE argument are mutually exclusive
FAIL cannot set 'key@sfc': --file and VALUE argument are mutually exclusive

View file

@ -1,2 +1,2 @@
$ pda set a b --ttl 3343r --> FAIL
FAIL invalid argument "3343r" for "-t, --ttl" flag: time: unknown unit "r" in duration "3343r"
FAIL invalid argument "3343r" for "-t, --ttl" flag: time: unknown unit "r" in duration "3343r"

View file

@ -2,7 +2,7 @@ $ pda set key@ss "original" --safe
$ pda get key@ss
"original"
$ pda set key@ss "overwritten" --safe
info skipped 'key@ss': already exists
info skipped 'key@ss': already exists
$ pda get key@ss
"original"
$ pda set newkey@ss "fresh" --safe

View file

@ -2,4 +2,4 @@
$ fecho tpl {{ enum .LEVEL "info" "warn" }}
$ pda set level@tple < tpl
$ pda get level@tple LEVEL=debug --> FAIL
FAIL cannot get 'level@tple': template: cmd:1:3: executing "cmd" at <enum .LEVEL "info" "warn">: error calling enum: invalid value 'debug', allowed: [info warn]
FAIL cannot get 'level@tple': template: cmd:1:3: executing "cmd" at <enum .LEVEL "info" "warn">: error calling enum: invalid value 'debug', allowed: [info warn]

View file

@ -2,4 +2,4 @@
$ fecho tpl {{ require .FILE }}
$ pda set tmpl@tplr < tpl
$ pda get tmpl@tplr --> FAIL
FAIL cannot get 'tmpl@tplr': template: cmd:1:3: executing "cmd" at <require .FILE>: error calling require: required value is missing or empty
FAIL cannot get 'tmpl@tplr': template: cmd:1:3: executing "cmd" at <require .FILE>: error calling require: required value is missing or empty