feat: command rename finalising
This commit is contained in:
parent
8ea865b2ce
commit
a4d2e919dc
15 changed files with 22 additions and 33 deletions
|
|
@ -35,7 +35,7 @@ import (
|
||||||
var delStoreCmd = &cobra.Command{
|
var delStoreCmd = &cobra.Command{
|
||||||
Use: "remove-store STORE",
|
Use: "remove-store STORE",
|
||||||
Short: "Delete a store",
|
Short: "Delete a store",
|
||||||
Aliases: []string{"rm-store", "rms"},
|
Aliases: []string{"rms"},
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: delStore,
|
RunE: delStore,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import (
|
||||||
var exportCmd = &cobra.Command{
|
var exportCmd = &cobra.Command{
|
||||||
Use: "export [STORE]",
|
Use: "export [STORE]",
|
||||||
Short: "Export store as NDJSON (alias for list --format ndjson)",
|
Short: "Export store as NDJSON (alias for list --format ndjson)",
|
||||||
Aliases: []string{"dump"},
|
Aliases: []string{},
|
||||||
Args: cobra.MaximumNArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
listFormat = "ndjson"
|
listFormat = "ndjson"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
var identityCmd = &cobra.Command{
|
var identityCmd = &cobra.Command{
|
||||||
Use: "identity",
|
Use: "identity",
|
||||||
|
Aliases: []string{"id"},
|
||||||
Short: "Show or create the age encryption identity",
|
Short: "Show or create the age encryption identity",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: identityRun,
|
RunE: identityRun,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import (
|
||||||
var listStoresCmd = &cobra.Command{
|
var listStoresCmd = &cobra.Command{
|
||||||
Use: "list-stores",
|
Use: "list-stores",
|
||||||
Short: "List all stores",
|
Short: "List all stores",
|
||||||
Aliases: []string{"ls-stores", "lss"},
|
Aliases: []string{"lss"},
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: listStores,
|
RunE: listStores,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import (
|
||||||
var restoreCmd = &cobra.Command{
|
var restoreCmd = &cobra.Command{
|
||||||
Use: "import [STORE]",
|
Use: "import [STORE]",
|
||||||
Short: "Restore key/value pairs from an NDJSON dump",
|
Short: "Restore key/value pairs from an NDJSON dump",
|
||||||
Aliases: []string{"restore"},
|
Aliases: []string{},
|
||||||
Args: cobra.MaximumNArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
RunE: restore,
|
RunE: restore,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
|
|
|
||||||
4
testdata/dump__key__ok.ct
vendored
4
testdata/dump__key__ok.ct
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
$ pda set a1 1
|
$ pda set a1 1
|
||||||
$ pda set a2 2
|
$ pda set a2 2
|
||||||
$ pda set b1 3
|
$ pda set b1 3
|
||||||
$ pda dump --key "a*"
|
$ pda export --key "a*"
|
||||||
{"key":"a1","value":"1","encoding":"text"}
|
{"key":"a1","value":"1","encoding":"text"}
|
||||||
{"key":"a2","value":"2","encoding":"text"}
|
{"key":"a2","value":"2","encoding":"text"}
|
||||||
$ pda dump --key "c*" --> FAIL
|
$ pda export --key "c*" --> FAIL
|
||||||
FAIL cannot ls '@default': no matches for key pattern 'c*'
|
FAIL cannot ls '@default': no matches for key pattern 'c*'
|
||||||
|
|
|
||||||
4
testdata/dump__value__ok.ct
vendored
4
testdata/dump__value__ok.ct
vendored
|
|
@ -2,7 +2,7 @@ $ pda set url https://example.com
|
||||||
$ fecho tmpval hello world
|
$ fecho tmpval hello world
|
||||||
$ pda set greeting < tmpval
|
$ pda set greeting < tmpval
|
||||||
$ pda set number 42
|
$ pda set number 42
|
||||||
$ pda dump --value "**https**"
|
$ pda export --value "**https**"
|
||||||
{"key":"url","value":"https://example.com","encoding":"text"}
|
{"key":"url","value":"https://example.com","encoding":"text"}
|
||||||
$ pda dump --value "**world**"
|
$ pda export --value "**world**"
|
||||||
{"key":"greeting","value":"hello world\n","encoding":"text"}
|
{"key":"greeting","value":"hello world\n","encoding":"text"}
|
||||||
|
|
|
||||||
10
testdata/help__dump__ok.ct
vendored
10
testdata/help__dump__ok.ct
vendored
|
|
@ -1,13 +1,10 @@
|
||||||
$ pda help dump
|
$ pda help export
|
||||||
$ pda dump --help
|
$ pda export --help
|
||||||
Export store as NDJSON (alias for list --format ndjson)
|
Export store as NDJSON (alias for list --format ndjson)
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
pda export [STORE] [flags]
|
pda export [STORE] [flags]
|
||||||
|
|
||||||
Aliases:
|
|
||||||
export, dump
|
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for export
|
-h, --help help for export
|
||||||
-k, --key strings Filter keys with glob pattern (repeatable)
|
-k, --key strings Filter keys with glob pattern (repeatable)
|
||||||
|
|
@ -17,9 +14,6 @@ Export store as NDJSON (alias for list --format ndjson)
|
||||||
Usage:
|
Usage:
|
||||||
pda export [STORE] [flags]
|
pda export [STORE] [flags]
|
||||||
|
|
||||||
Aliases:
|
|
||||||
export, dump
|
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for export
|
-h, --help help for export
|
||||||
-k, --key strings Filter keys with glob pattern (repeatable)
|
-k, --key strings Filter keys with glob pattern (repeatable)
|
||||||
|
|
|
||||||
4
testdata/help__list-dbs__ok.ct
vendored
4
testdata/help__list-dbs__ok.ct
vendored
|
|
@ -6,7 +6,7 @@ Usage:
|
||||||
pda list-stores [flags]
|
pda list-stores [flags]
|
||||||
|
|
||||||
Aliases:
|
Aliases:
|
||||||
list-stores, ls-stores, lss
|
list-stores, lss
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for list-stores
|
-h, --help help for list-stores
|
||||||
|
|
@ -16,7 +16,7 @@ Usage:
|
||||||
pda list-stores [flags]
|
pda list-stores [flags]
|
||||||
|
|
||||||
Aliases:
|
Aliases:
|
||||||
list-stores, ls-stores, lss
|
list-stores, lss
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for list-stores
|
-h, --help help for list-stores
|
||||||
|
|
|
||||||
4
testdata/help__remove-store__ok.ct
vendored
4
testdata/help__remove-store__ok.ct
vendored
|
|
@ -6,7 +6,7 @@ Usage:
|
||||||
pda remove-store STORE [flags]
|
pda remove-store STORE [flags]
|
||||||
|
|
||||||
Aliases:
|
Aliases:
|
||||||
remove-store, rm-store, rms
|
remove-store, rms
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for remove-store
|
-h, --help help for remove-store
|
||||||
|
|
@ -17,7 +17,7 @@ Usage:
|
||||||
pda remove-store STORE [flags]
|
pda remove-store STORE [flags]
|
||||||
|
|
||||||
Aliases:
|
Aliases:
|
||||||
remove-store, rm-store, rms
|
remove-store, rms
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for remove-store
|
-h, --help help for remove-store
|
||||||
|
|
|
||||||
10
testdata/help__restore__ok.ct
vendored
10
testdata/help__restore__ok.ct
vendored
|
|
@ -1,13 +1,10 @@
|
||||||
$ pda help restore
|
$ pda help import
|
||||||
$ pda restore --help
|
$ pda import --help
|
||||||
Restore key/value pairs from an NDJSON dump
|
Restore key/value pairs from an NDJSON dump
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
pda import [STORE] [flags]
|
pda import [STORE] [flags]
|
||||||
|
|
||||||
Aliases:
|
|
||||||
import, restore
|
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
--drop Drop existing entries before restoring (full replace)
|
--drop Drop existing entries before restoring (full replace)
|
||||||
-f, --file string Path to an NDJSON dump (defaults to stdin)
|
-f, --file string Path to an NDJSON dump (defaults to stdin)
|
||||||
|
|
@ -19,9 +16,6 @@ Restore key/value pairs from an NDJSON dump
|
||||||
Usage:
|
Usage:
|
||||||
pda import [STORE] [flags]
|
pda import [STORE] [flags]
|
||||||
|
|
||||||
Aliases:
|
|
||||||
import, restore
|
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
--drop Drop existing entries before restoring (full replace)
|
--drop Drop existing entries before restoring (full replace)
|
||||||
-f, --file string Path to an NDJSON dump (defaults to stdin)
|
-f, --file string Path to an NDJSON dump (defaults to stdin)
|
||||||
|
|
|
||||||
2
testdata/restore__drop__ok.ct
vendored
2
testdata/restore__drop__ok.ct
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
$ pda set existing keep-me
|
$ pda set existing keep-me
|
||||||
$ pda set other also-keep
|
$ pda set other also-keep
|
||||||
$ fecho dumpfile {"key":"new","value":"hello","encoding":"text"}
|
$ fecho dumpfile {"key":"new","value":"hello","encoding":"text"}
|
||||||
$ pda restore --drop --file dumpfile
|
$ pda import --drop --file dumpfile
|
||||||
ok restored 1 entries into @default
|
ok restored 1 entries into @default
|
||||||
$ pda get new
|
$ pda get new
|
||||||
hello
|
hello
|
||||||
|
|
|
||||||
4
testdata/restore__key__ok.ct
vendored
4
testdata/restore__key__ok.ct
vendored
|
|
@ -3,7 +3,7 @@ $ pda set a2 2
|
||||||
$ pda set b1 3
|
$ pda set b1 3
|
||||||
$ fecho dumpfile {"key":"a1","value":"1","encoding":"text"} {"key":"a2","value":"2","encoding":"text"} {"key":"b1","value":"3","encoding":"text"}
|
$ 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 rm a1 a2 b1
|
||||||
$ pda restore --key "a*" --file dumpfile
|
$ pda import --key "a*" --file dumpfile
|
||||||
ok restored 2 entries into @default
|
ok restored 2 entries into @default
|
||||||
$ pda get a1
|
$ pda get a1
|
||||||
1
|
1
|
||||||
|
|
@ -12,5 +12,5 @@ $ pda get a2
|
||||||
$ pda get b1 --> FAIL
|
$ pda get b1 --> FAIL
|
||||||
FAIL cannot get 'b1': no such key
|
FAIL cannot get 'b1': no such key
|
||||||
hint did you mean 'a1'?
|
hint did you mean 'a1'?
|
||||||
$ pda restore --key "c*" --file dumpfile --> FAIL
|
$ pda import --key "c*" --file dumpfile --> FAIL
|
||||||
FAIL cannot restore '@default': no matches for key pattern 'c*'
|
FAIL cannot restore '@default': no matches for key pattern 'c*'
|
||||||
|
|
|
||||||
2
testdata/restore__merge__ok.ct
vendored
2
testdata/restore__merge__ok.ct
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
# Merge import updates existing entries and adds new ones
|
# Merge import updates existing entries and adds new ones
|
||||||
$ pda set existing@mrg old-value
|
$ pda set existing@mrg old-value
|
||||||
$ fecho dumpfile {"key":"existing","value":"updated","encoding":"text"} {"key":"new","value":"hello","encoding":"text"}
|
$ fecho dumpfile {"key":"existing","value":"updated","encoding":"text"} {"key":"new","value":"hello","encoding":"text"}
|
||||||
$ pda restore mrg --file dumpfile
|
$ pda import mrg --file dumpfile
|
||||||
ok restored 2 entries into @mrg
|
ok restored 2 entries into @mrg
|
||||||
$ pda get existing@mrg
|
$ pda get existing@mrg
|
||||||
updated
|
updated
|
||||||
|
|
|
||||||
2
testdata/restore__stdin__ok.ct
vendored
2
testdata/restore__stdin__ok.ct
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
# Import from stdin preserves existing entries
|
# Import from stdin preserves existing entries
|
||||||
$ pda set existing@stn keep-me
|
$ pda set existing@stn keep-me
|
||||||
$ fecho dumpfile {"key":"new","value":"hello","encoding":"text"}
|
$ fecho dumpfile {"key":"new","value":"hello","encoding":"text"}
|
||||||
$ pda restore stn < dumpfile
|
$ pda import stn < dumpfile
|
||||||
ok restored 1 entries into @stn
|
ok restored 1 entries into @stn
|
||||||
$ pda get existing@stn
|
$ pda get existing@stn
|
||||||
keep-me
|
keep-me
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue