feat: splits --glob into --key and --value searches

This commit is contained in:
Lewis Wynne 2026-02-11 15:21:05 +00:00
parent 1f4732823d
commit 5145816b0a
22 changed files with 275 additions and 188 deletions

View file

@ -1,8 +1,8 @@
$ pda set a1 1
$ pda set a2 2
$ pda set b1 3
$ pda dump --glob a*
$ pda dump --key "a*"
{"key":"a1","value":"1","encoding":"text"}
{"key":"a2","value":"2","encoding":"text"}
$ pda dump --glob c* --> FAIL
FAIL cannot ls '@default': no matches for pattern 'c*'
$ pda dump --key "c*" --> FAIL
FAIL cannot ls '@default': no matches for key pattern 'c*'

8
testdata/dump__value__ok.ct vendored Normal file
View file

@ -0,0 +1,8 @@
$ pda set url https://example.com
$ fecho tmpval hello world
$ pda set greeting < tmpval
$ pda set number 42
$ pda dump --value "**https**"
{"key":"url","value":"https://example.com","encoding":"text"}
$ pda dump --value "**world**"
{"key":"greeting","value":"hello world\n","encoding":"text"}

View file

@ -9,9 +9,9 @@ Aliases:
export, dump
Flags:
-g, --glob strings Filter keys with glob pattern (repeatable)
--glob-sep string Characters treated as separators for globbing (default '/-_.@: ')
-h, --help help for export
-h, --help help for export
-k, --key strings Filter keys with glob pattern (repeatable)
-v, --value strings Filter values with regex pattern (repeatable)
Export store as NDJSON (alias for list --format ndjson)
Usage:
@ -21,6 +21,6 @@ Aliases:
export, dump
Flags:
-g, --glob strings Filter keys with glob pattern (repeatable)
--glob-sep string Characters treated as separators for globbing (default '/-_.@: ')
-h, --help help for export
-h, --help help for export
-k, --key strings Filter keys with glob pattern (repeatable)
-v, --value strings Filter values with regex pattern (repeatable)

View file

@ -9,16 +9,16 @@ Aliases:
list, ls
Flags:
-b, --base64 view binary data as base64
-o, --format format output format (table|tsv|csv|markdown|html|ndjson) (default table)
-f, --full show full values without truncation
-g, --glob strings Filter keys with glob pattern (repeatable)
--glob-sep string Characters treated as separators for globbing (default '/-_.@: ')
-h, --help help for list
--no-header suppress the header row
--no-keys suppress the key column
--no-ttl suppress the TTL column
--no-values suppress the value column
-b, --base64 view binary data as base64
-o, --format format output format (table|tsv|csv|markdown|html|ndjson) (default table)
-f, --full show full values without truncation
-h, --help help for list
-k, --key strings Filter keys with glob pattern (repeatable)
--no-header suppress the header row
--no-keys suppress the key column
--no-ttl suppress the TTL column
--no-values suppress the value column
-v, --value strings Filter values with regex pattern (repeatable)
List the contents of a store
Usage:
@ -28,13 +28,13 @@ Aliases:
list, ls
Flags:
-b, --base64 view binary data as base64
-o, --format format output format (table|tsv|csv|markdown|html|ndjson) (default table)
-f, --full show full values without truncation
-g, --glob strings Filter keys with glob pattern (repeatable)
--glob-sep string Characters treated as separators for globbing (default '/-_.@: ')
-h, --help help for list
--no-header suppress the header row
--no-keys suppress the key column
--no-ttl suppress the TTL column
--no-values suppress the value column
-b, --base64 view binary data as base64
-o, --format format output format (table|tsv|csv|markdown|html|ndjson) (default table)
-f, --full show full values without truncation
-h, --help help for list
-k, --key strings Filter keys with glob pattern (repeatable)
--no-header suppress the header row
--no-keys suppress the key column
--no-ttl suppress the TTL column
--no-values suppress the value column
-v, --value strings Filter values with regex pattern (repeatable)

View file

@ -9,10 +9,9 @@ Aliases:
remove, rm
Flags:
-g, --glob strings Delete keys matching glob pattern (repeatable)
--glob-sep string Characters treated as separators for globbing (default '/-_.@: ')
-h, --help help for remove
-i, --interactive Prompt yes/no for each deletion
-h, --help help for remove
-i, --interactive Prompt yes/no for each deletion
-k, --key strings Delete keys matching glob pattern (repeatable)
Delete one or more keys
Usage:
@ -22,7 +21,6 @@ Aliases:
remove, rm
Flags:
-g, --glob strings Delete keys matching glob pattern (repeatable)
--glob-sep string Characters treated as separators for globbing (default '/-_.@: ')
-h, --help help for remove
-i, --interactive Prompt yes/no for each deletion
-h, --help help for remove
-i, --interactive Prompt yes/no for each deletion
-k, --key strings Delete keys matching glob pattern (repeatable)

View file

@ -9,12 +9,11 @@ Aliases:
import, restore
Flags:
--drop Drop existing entries before restoring (full replace)
-f, --file string Path to an NDJSON dump (defaults to stdin)
-g, --glob strings Restore keys matching glob pattern (repeatable)
--glob-sep string Characters treated as separators for globbing (default '/-_.@: ')
-h, --help help for import
-i, --interactive Prompt before overwriting existing keys
--drop Drop existing entries before restoring (full replace)
-f, --file string Path to an NDJSON dump (defaults to stdin)
-h, --help help for import
-i, --interactive Prompt before overwriting existing keys
-k, --key strings Restore keys matching glob pattern (repeatable)
Restore key/value pairs from an NDJSON dump
Usage:
@ -24,9 +23,8 @@ Aliases:
import, restore
Flags:
--drop Drop existing entries before restoring (full replace)
-f, --file string Path to an NDJSON dump (defaults to stdin)
-g, --glob strings Restore keys matching glob pattern (repeatable)
--glob-sep string Characters treated as separators for globbing (default '/-_.@: ')
-h, --help help for import
-i, --interactive Prompt before overwriting existing keys
--drop Drop existing entries before restoring (full replace)
-f, --file string Path to an NDJSON dump (defaults to stdin)
-h, --help help for import
-i, --interactive Prompt before overwriting existing keys
-k, --key strings Restore keys matching glob pattern (repeatable)

View file

@ -1,12 +0,0 @@
$ pda set a1@lg 1
$ pda set a2@lg 2
$ pda set b1@lg 3
$ pda ls lg --glob a* --format tsv
Key Value TTL
a1 1 no expiry
a2 2 no expiry
$ pda ls lg --glob b* --format tsv
Key Value TTL
b1 3 no expiry
$ pda ls lg --glob c* --> FAIL
FAIL cannot ls '@lg': no matches for pattern 'c*'

12
testdata/list__key__ok.ct vendored Normal file
View file

@ -0,0 +1,12 @@
$ pda set a1@lg 1
$ pda set a2@lg 2
$ pda set b1@lg 3
$ pda ls lg --key "a*" --format tsv
Key Value TTL
a1 1 no expiry
a2 2 no expiry
$ pda ls lg --key "b*" --format tsv
Key Value TTL
b1 3 no expiry
$ pda ls lg --key "c*" --> FAIL
FAIL cannot ls '@lg': no matches for key pattern 'c*'

11
testdata/list__key__value__ok.ct vendored Normal file
View file

@ -0,0 +1,11 @@
$ pda set dburl@kv postgres://localhost:5432
$ pda set apiurl@kv https://api.example.com
$ pda set dbpass@kv s3cret
$ pda ls kv -k "db*" -v "**localhost**" --format tsv
Key Value TTL
dburl postgres://localhost:5432 no expiry
$ pda ls kv -k "*url*" -v "**example**" --format tsv
Key Value TTL
apiurl 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**'

8
testdata/list__value__multi__ok.ct vendored Normal file
View file

@ -0,0 +1,8 @@
$ pda set url@vm https://example.com
$ fecho tmpval hello world
$ pda set greeting@vm < tmpval
$ pda set number@vm 42
$ pda ls vm --value "**world**" --value "42" --format tsv
Key Value TTL
greeting hello world (..1 more chars) no expiry
number 42 no expiry

15
testdata/list__value__ok.ct vendored Normal file
View file

@ -0,0 +1,15 @@
$ pda set url@vt https://example.com
$ fecho tmpval hello world
$ pda set greeting@vt < tmpval
$ pda set number@vt 42
$ pda ls vt --value "**world**" --format tsv
Key Value TTL
greeting hello world (..1 more chars) no expiry
$ pda ls vt --value "**https**" --format tsv
Key Value TTL
url https://example.com no expiry
$ pda ls vt --value "*" --format tsv
Key Value TTL
number 42 no expiry
$ pda ls vt --value "**nomatch**" --> FAIL
FAIL cannot ls '@vt': no matches for value pattern '**nomatch**'

View file

@ -1,16 +1,19 @@
$ pda set foo 1
$ pda set bar 2
$ pda ls
Key Value TTL
a echo hello (..1 more chars) no expiry
a1 1 no expiry
a2 2 no expiry
b1 3 no expiry
bar 2 no expiry
copied-key hidden-value no expiry
foo 1 no expiry
moved-key hidden-value no expiry
$ pda rm foo --glob "*"
Key Value TTL
a echo hello (..1 more chars) no expiry
a1 1 no expiry
a2 2 no expiry
b1 3 no expiry
bar 2 no expiry
copied-key hidden-value no expiry
foo 1 no expiry
greeting hello world (..1 more chars) no expiry
moved-key hidden-value no expiry
number 42 no expiry
url https://example.com no expiry
$ pda rm foo --key "*"
$ pda get bar --> FAIL
FAIL cannot get 'bar': no such key
$ pda get foo --> FAIL

View file

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

View file

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

View file

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