Skip to content

Commit e46b455

Browse files
committed
refactor: use aperturerobotics/cli
Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent 445d367 commit e46b455

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

cmd/kvfile/main.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"context"
54
"encoding/json"
65
"fmt"
76
"io"
@@ -12,7 +11,7 @@ import (
1211
kvfile_compress "github.com/aperturerobotics/go-kvfile/compress"
1312
b58 "github.com/mr-tron/base58/base58"
1413
"github.com/pkg/errors"
15-
"github.com/urfave/cli/v3"
14+
"github.com/aperturerobotics/cli"
1615
)
1716

1817
var (
@@ -25,11 +24,11 @@ var (
2524
)
2625

2726
func main() {
28-
app := &cli.Command{
27+
app := &cli.App{
2928
Name: "kvfile",
3029
Usage: "A CLI tool for working with key-value files",
31-
Authors: []any{
32-
"Christian Stewart <christian@aperture.us>",
30+
Authors: []*cli.Author{
31+
{Name: "Christian Stewart", Email: "christian@aperture.us"},
3332
},
3433
Flags: []cli.Flag{
3534
&cli.BoolFlag{
@@ -62,7 +61,7 @@ func main() {
6261
{
6362
Name: "count",
6463
Usage: "Print the number of keys in a k/v file.",
65-
Action: func(ctx context.Context, c *cli.Command) error {
64+
Action: func(c *cli.Context) error {
6665
reader, rel, err := openKVFile(filePath)
6766
if rel != nil {
6867
defer rel()
@@ -79,7 +78,7 @@ func main() {
7978
{
8079
Name: "keys",
8180
Usage: "Print all keys in a k/v file in sorted order.",
82-
Action: func(ctx context.Context, c *cli.Command) error {
81+
Action: func(c *cli.Context) error {
8382
reader, rel, err := openKVFile(filePath)
8483
if rel != nil {
8584
defer rel()
@@ -94,7 +93,7 @@ func main() {
9493
{
9594
Name: "values",
9695
Usage: "Print all key-value pairs in a k/v file.",
97-
Action: func(ctx context.Context, c *cli.Command) error {
96+
Action: func(c *cli.Context) error {
9897
reader, rel, err := openKVFile(filePath)
9998
if rel != nil {
10099
defer rel()
@@ -117,7 +116,7 @@ func main() {
117116
Destination: &keyStr,
118117
},
119118
},
120-
Action: func(ctx context.Context, c *cli.Command) error {
119+
Action: func(c *cli.Context) error {
121120
if keyStr == "" {
122121
return fmt.Errorf("please provide a key")
123122
}
@@ -152,7 +151,7 @@ func main() {
152151
Destination: &valueStr,
153152
},
154153
},
155-
Action: func(ctx context.Context, c *cli.Command) error {
154+
Action: func(c *cli.Context) error {
156155
if filePath == "" {
157156
return fmt.Errorf("please provide a file path")
158157
}
@@ -191,7 +190,7 @@ func main() {
191190
},
192191
}
193192

194-
err := app.Run(context.Background(), os.Args)
193+
err := app.Run(os.Args)
195194
if err != nil {
196195
os.Stderr.WriteString(err.Error() + "\n")
197196
os.Exit(1)

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ require (
1212

1313
require (
1414
github.com/SaveTheRbtz/zstd-seekable-format-go v0.6.1
15+
github.com/aperturerobotics/cli v1.0.0
1516
github.com/klauspost/compress v1.18.0
1617
github.com/mr-tron/base58 v1.2.0
1718
github.com/pkg/errors v0.9.1
18-
github.com/urfave/cli/v3 v3.1.1
1919
)
2020

2121
require (
2222
github.com/cespare/xxhash/v2 v2.2.0 // indirect
2323
github.com/google/btree v1.1.2 // indirect
24+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
2425
go.uber.org/atomic v1.10.0 // indirect
2526
go.uber.org/multierr v1.9.0 // indirect
2627
go.uber.org/zap v1.24.0 // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
github.com/SaveTheRbtz/zstd-seekable-format-go v0.6.1 h1:VuaOpU/0Aklkjcq8KBisGC862WTlf8bPbW3hqBrR6gs=
22
github.com/SaveTheRbtz/zstd-seekable-format-go v0.6.1/go.mod h1:IfUnG57D5yphwHgIIeIl74Gp5VCu74GsE7h3riM4cxs=
3+
github.com/aperturerobotics/cli v1.0.0 h1:s3xT2h7eBih4/4yZKTn/HQ6P+qpk6ygWZl2416xAI1M=
4+
github.com/aperturerobotics/cli v1.0.0/go.mod h1:wtlINjMcKuwyV1x4ftReuA6hHZcPB8kPMXHyQqGFCSc=
35
github.com/aperturerobotics/common v0.21.2 h1:fqnPL5Oovpd8nDaNBYGiD1UpZhcH/JfpsS8gt5iBDyA=
46
github.com/aperturerobotics/common v0.21.2/go.mod h1:FrecdNcsYvVS8RcWCR8FUkKFh+XmouFOYKHpBdMqqBA=
57
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20240713111131-be6bf89c3008 h1:So9JeziaWKx2Fw8sK4AUN/szqKtJ0jEMhS6bU4sHbxs=
@@ -26,8 +28,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
2628
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2729
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
2830
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
29-
github.com/urfave/cli/v3 v3.1.1 h1:bNnl8pFI5dxPOjeONvFCDFoECLQsceDG4ejahs4Jtxk=
30-
github.com/urfave/cli/v3 v3.1.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
31+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
32+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
3133
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
3234
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
3335
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=

0 commit comments

Comments
 (0)