Skip to content

Commit f9ae0b6

Browse files
committed
Upgrade kong to 1.4.0
1 parent 798c082 commit f9ae0b6

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/jotaen/klog
33
go 1.23
44

55
require (
6-
cloud.google.com/go v0.115.1
7-
github.com/alecthomas/kong v0.9.0
6+
cloud.google.com/go v0.116.0
7+
github.com/alecthomas/kong v1.4.0
88
github.com/jotaen/genie v0.0.1
99
github.com/jotaen/kong-completion v0.0.6
1010
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
cloud.google.com/go v0.115.1 h1:Jo0SM9cQnSkYfp44+v+NQXHpcHqlnRJk2qxh6yvxxxQ=
2-
cloud.google.com/go v0.115.1/go.mod h1:DuujITeaufu3gL68/lOFIirVNJwQeyf5UXyi+Wbgknc=
3-
github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
4-
github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
5-
github.com/alecthomas/kong v0.9.0 h1:G5diXxc85KvoV2f0ZRVuMsi45IrBgx9zDNGNj165aPA=
6-
github.com/alecthomas/kong v0.9.0/go.mod h1:Y47y5gKfHp1hDc7CH7OeXgLIpp+Q2m1Ni0L5s3bI8Os=
1+
cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE=
2+
cloud.google.com/go v0.116.0/go.mod h1:cEPSRWPzZEswwdr9BxE6ChEn01dWlTaF05LiC2Xs70U=
3+
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
4+
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
5+
github.com/alecthomas/kong v1.4.0 h1:UL7tzGMnnY0YRMMvJyITIRX1EpO6RbBRZDNcCevy3HA=
6+
github.com/alecthomas/kong v1.4.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU=
77
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
88
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
99
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

klog/app/error.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ type Error interface {
4343
// Error returns the error message.
4444
Error() string
4545

46+
Is(error) bool
47+
4648
// Details returns additional details, such as a hint how to solve the problem.
4749
Details() string
4850

@@ -72,6 +74,11 @@ func (e AppError) Error() string {
7274
return e.message
7375
}
7476

77+
func (e AppError) Is(err error) bool {
78+
_, ok := err.(AppError)
79+
return ok
80+
}
81+
7582
func (e AppError) Details() string {
7683
return e.details
7784
}
@@ -101,6 +108,11 @@ func (pe parserErrors) Error() string {
101108
return fmt.Sprintf("%d parsing error(s)", len(pe.errors))
102109
}
103110

111+
func (e parserErrors) Is(err error) bool {
112+
_, ok := err.(parserErrors)
113+
return ok
114+
}
115+
104116
func (pe parserErrors) Details() string {
105117
return fmt.Sprintf("%d parsing error(s)", len(pe.errors))
106118
}

klog/app/main/cli.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,16 @@ func Run(homeDir app.File, meta app.Meta, config app.Config, args []string) (int
9696

9797
rErr := kongCtx.Run()
9898
if rErr != nil {
99-
switch e := rErr.(type) {
100-
case app.ParserErrors:
99+
if errors.Is(rErr, app.NewParserErrors(nil)) {
100+
var e app.ParserErrors
101+
errors.As(rErr, &e)
101102
return e.Code().ToInt(), util.PrettifyParsingError(e, styler)
102-
case app.Error:
103+
} else if errors.Is(rErr, app.NewError("", "", nil)) {
104+
var e app.Error
105+
errors.As(rErr, &e)
103106
return e.Code().ToInt(), util.PrettifyAppError(e, config.IsDebug.Value())
104-
default:
105-
return app.GENERAL_ERROR.ToInt(), errors.New("Error: " + e.Error())
107+
} else {
108+
return app.GENERAL_ERROR.ToInt(), errors.New("Error: " + rErr.Error())
106109
}
107110
}
108111
return 0, nil

0 commit comments

Comments
 (0)