Skip to content

Commit a0b0a54

Browse files
chore: Update module github.com/urfave/cli/v2 to v3 (#137)
* chore: Update module github.com/urfave/cli/v2 to v3 * fix --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: MuZhou233 <muzhou233@outlook.com>
1 parent 70b1039 commit a0b0a54

File tree

7 files changed

+33
-35
lines changed

7 files changed

+33
-35
lines changed

cmd/admin.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package cmd
22

33
import (
4+
"context"
5+
46
"github.com/tuihub/librarian/internal/conf"
57
"github.com/tuihub/librarian/internal/lib/libapp"
68
"github.com/tuihub/librarian/internal/lib/libzap"
79

8-
"github.com/urfave/cli/v2"
10+
"github.com/urfave/cli/v3"
911
)
1012

1113
const (
@@ -18,11 +20,11 @@ func newCmdAdmin() *cli.Command {
1820
return &cli.Command{
1921
Name: "admin",
2022
Usage: "Administrative commands",
21-
Subcommands: []*cli.Command{
23+
Commands: []*cli.Command{
2224
{
2325
Name: "user",
2426
Usage: "User management commands",
25-
Subcommands: []*cli.Command{
27+
Commands: []*cli.Command{
2628
{
2729
Name: "create",
2830
Usage: "Create a new user",
@@ -52,16 +54,16 @@ func newCmdAdmin() *cli.Command {
5254
}
5355
}
5456

55-
func runCmdAdminCreateUser(ctx *cli.Context) error {
57+
func runCmdAdminCreateUser(ctx context.Context, cmd *cli.Command) error {
5658
stdLogger := libzap.NewStdout(libzap.InfoLevel).Sugar()
5759
appSettings, err := libapp.NewAppSettings(
5860
id,
5961
name,
6062
version,
6163
protoVersion,
6264
date,
63-
ctx.String(cmdServeFlagConfig),
64-
ctx.String(cmdServeFlagData),
65+
cmd.String(cmdServeFlagConfig),
66+
cmd.String(cmdServeFlagData),
6567
)
6668
if err != nil {
6769
stdLogger.Fatalf("Initialize failed: %v", err)
@@ -85,13 +87,13 @@ func runCmdAdminCreateUser(ctx *cli.Context) error {
8587
stdLogger.Fatalf("Initialize failed: %v", err)
8688
}
8789
defer cleanup()
88-
username := ctx.String(cmdAdminFlagUsername)
89-
password := ctx.String(cmdAdminFlagPassword)
90-
isAdmin := ctx.Bool(cmdAdminFlagAdmin)
90+
username := cmd.String(cmdAdminFlagUsername)
91+
password := cmd.String(cmdAdminFlagPassword)
92+
isAdmin := cmd.Bool(cmdAdminFlagAdmin)
9193
if username == "" || password == "" {
9294
stdLogger.Fatalf("Username and password are required")
9395
}
94-
err = app.CliCreateUser(ctx.Context, username, password, isAdmin)
96+
err = app.CliCreateUser(ctx, username, password, isAdmin)
9597
if err != nil {
9698
stdLogger.Fatalf("Create user failed: %v", err)
9799
}

cmd/cmd.go

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

33
import (
4-
"github.com/urfave/cli/v2"
4+
"github.com/urfave/cli/v3"
55
)
66

77
var (
@@ -19,13 +19,13 @@ var (
1919
protoVersion string //nolint:gochecknoglobals //no need
2020
)
2121

22-
func NewCmd(_name, _version, _id, _date, _protoVersion string) *cli.App {
22+
func NewCmd(_name, _version, _id, _date, _protoVersion string) *cli.Command {
2323
name = _name
2424
version = _version
2525
id = _id
2626
date = _date
2727
protoVersion = _protoVersion
28-
return &cli.App{
28+
return &cli.Command{
2929
Name: "TuiHub Librarian",
3030
Usage: "Librarian is the standard server implementation of TuiHub",
3131
Commands: []*cli.Command{

cmd/config.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package cmd
22

33
import (
4+
"context"
5+
46
"github.com/tuihub/librarian/internal/conf"
57
"github.com/tuihub/librarian/internal/lib/libapp"
68
"github.com/tuihub/librarian/internal/lib/libzap"
79

8-
"github.com/urfave/cli/v2"
10+
"github.com/urfave/cli/v3"
911
)
1012

1113
func newCmdConfig() *cli.Command {
1214
return &cli.Command{
1315
Name: "config",
1416
Usage: "Configuration commands",
15-
Subcommands: []*cli.Command{
17+
Commands: []*cli.Command{
1618
{
1719
Name: "check",
1820
Usage: "Validate configuration file",
@@ -31,7 +33,7 @@ func newCmdConfig() *cli.Command {
3133
}
3234
}
3335

34-
func runCmdConfigCheck(ctx *cli.Context) error {
36+
func runCmdConfigCheck(ctx context.Context, cmd *cli.Command) error {
3537
stdLogger := libzap.NewStdout(libzap.InfoLevel).Sugar()
3638
stdLogger.Infof("=== Configuring ===")
3739
stdLogger.Infof("[Service\t] Name: %s", name)
@@ -42,8 +44,8 @@ func runCmdConfigCheck(ctx *cli.Context) error {
4244
version,
4345
protoVersion,
4446
date,
45-
ctx.String(cmdServeFlagConfig),
46-
ctx.String(cmdServeFlagData),
47+
cmd.String(cmdServeFlagConfig),
48+
cmd.String(cmdServeFlagData),
4749
)
4850
if err != nil {
4951
stdLogger.Fatalf("Initialize failed: %v", err)

cmd/serve.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cmd
22

33
import (
4+
"context"
5+
46
"github.com/tuihub/librarian/internal/client"
57
"github.com/tuihub/librarian/internal/conf"
68
"github.com/tuihub/librarian/internal/lib/libapp"
@@ -18,7 +20,7 @@ import (
1820
"github.com/go-kratos/kratos/v2/transport/grpc"
1921
"github.com/go-kratos/kratos/v2/transport/http"
2022
"github.com/google/wire"
21-
"github.com/urfave/cli/v2"
23+
"github.com/urfave/cli/v3"
2224
"go.uber.org/zap"
2325
)
2426

@@ -81,7 +83,7 @@ func newApp(
8183
return kratos.New(options...), nil
8284
}
8385

84-
func runCmdServe(ctx *cli.Context) error {
86+
func runCmdServe(ctx context.Context, cmd *cli.Command) error {
8587
stdLogger := libzap.NewStdout(libzap.InfoLevel).Sugar()
8688
stdLogger.Infof("=== Configuring ===")
8789
stdLogger.Infof("[Service\t] Name: %s", name)
@@ -92,8 +94,8 @@ func runCmdServe(ctx *cli.Context) error {
9294
version,
9395
protoVersion,
9496
date,
95-
ctx.String(cmdServeFlagConfig),
96-
ctx.String(cmdServeFlagData),
97+
cmd.String(cmdServeFlagConfig),
98+
cmd.String(cmdServeFlagData),
9799
)
98100
if err != nil {
99101
stdLogger.Fatalf("Initialize failed: %v", err)

go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ require (
4949
github.com/spf13/afero v1.14.0
5050
github.com/stretchr/testify v1.10.0
5151
github.com/tuihub/protos v0.5.6
52-
github.com/urfave/cli/v2 v2.27.7
52+
github.com/urfave/cli/v3 v3.4.1
5353
go.opentelemetry.io/otel v1.37.0
5454
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.13.0
5555
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.13.0
@@ -115,7 +115,6 @@ require (
115115
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
116116
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
117117
github.com/cespare/xxhash/v2 v2.3.0 // indirect
118-
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
119118
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
120119
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
121120
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
@@ -188,7 +187,6 @@ require (
188187
github.com/robfig/cron/v3 v3.0.1 // indirect
189188
github.com/rs/cors v1.8.3 // indirect
190189
github.com/rs/xid v1.6.0 // indirect
191-
github.com/russross/blackfriday/v2 v2.1.0 // indirect
192190
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 // indirect
193191
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
194192
github.com/shirou/gopsutil/v3 v3.23.6 // indirect
@@ -205,7 +203,6 @@ require (
205203
github.com/valyala/tcplisten v1.0.0 // indirect
206204
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
207205
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
208-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
209206
github.com/yusufpapurcu/wmi v1.2.3 // indirect
210207
github.com/zclconf/go-cty v1.14.4 // indirect
211208
github.com/zclconf/go-cty-yaml v1.1.0 // indirect

go.sum

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
162162
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
163163
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
164164
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
165-
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
166-
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
167165
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
168166
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
169167
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -683,8 +681,6 @@ github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
683681
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
684682
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
685683
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
686-
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
687-
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
688684
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
689685
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 h1:GHRpF1pTW19a8tTFrMLUcfWwyC0pnifVo2ClaLq+hP8=
690686
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8=
@@ -767,8 +763,8 @@ github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs
767763
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
768764
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
769765
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
770-
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
771-
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
766+
github.com/urfave/cli/v3 v3.4.1 h1:1M9UOCy5bLmGnuu1yn3t3CB4rG79Rtoxuv1sPhnm6qM=
767+
github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
772768
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
773769
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
774770
github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA=
@@ -780,8 +776,6 @@ github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6Ac
780776
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
781777
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
782778
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
783-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
784-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
785779
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
786780
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
787781
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

main.go

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

33
import (
4+
"context"
45
"os"
56

67
"github.com/tuihub/librarian/cmd"
@@ -24,7 +25,7 @@ var (
2425

2526
func main() {
2627
app := cmd.NewCmd(name, version, id, date, protoVersion)
27-
if err := app.Run(os.Args); err != nil {
28+
if err := app.Run(context.Background(), os.Args); err != nil {
2829
panic(err)
2930
}
3031
}

0 commit comments

Comments
 (0)