Skip to content

Commit

Permalink
Upgrade to latest kong
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Feb 28, 2023
1 parent cb6e249 commit bf34e54
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
24 changes: 6 additions & 18 deletions cmd/participle/gen_lexer_cmd.go
Expand Up @@ -17,11 +17,11 @@ import (
)

type genLexerCmd struct {
Name string `help:"Name of the lexer."`
Output string `short:"o" help:"Output file."`
Tags string `help:"Build tags to include in the generated file."`
Package string `arg:"" required:"" help:"Go package for generated code."`
Lexer string `arg:"" default:"-" type:"existingfile" help:"JSON representation of a Participle lexer (read from stdin if omitted)."`
Name string `help:"Name of the lexer."`
Output string `short:"o" help:"Output file."`
Tags string `help:"Build tags to include in the generated file."`
Package string `arg:"" required:"" help:"Go package for generated code."`
Lexer *os.File `arg:"" default:"-" help:"JSON representation of a Participle lexer (read from stdin if omitted)."`
}

func (c *genLexerCmd) Help() string {
Expand All @@ -33,20 +33,8 @@ per token.
}

func (c *genLexerCmd) Run() error {
var r *os.File
if c.Lexer == "-" {
r = os.Stdin
} else {
var err error
r, err = os.Open(c.Lexer)
if err != nil {
return err
}
defer r.Close()
}

rules := lexer.Rules{}
err := json.NewDecoder(r).Decode(&rules)
err := json.NewDecoder(c.Lexer).Decode(&rules)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/participle/go.mod
Expand Up @@ -3,7 +3,7 @@ module github.com/alecthomas/participle/v2/cmd/participle
go 1.18

require (
github.com/alecthomas/kong v0.6.1
github.com/alecthomas/kong v0.7.1
github.com/alecthomas/participle/v2 v2.0.0-beta.5
)

Expand Down
2 changes: 2 additions & 0 deletions cmd/participle/go.sum
@@ -1,6 +1,8 @@
github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2ojoH/0=
github.com/alecthomas/kong v0.6.1 h1:1kNhcFepkR+HmasQpbiKDLylIL8yh5B5y1zPp5bJimA=
github.com/alecthomas/kong v0.6.1/go.mod h1:JfHWDzLmbh/puW6I3V7uWenoh56YNVONW+w8eKeUr9I=
github.com/alecthomas/kong v0.7.1 h1:azoTh0IOfwlAX3qN9sHWTxACE2oV8Bg2gAwBsMwDQY4=
github.com/alecthomas/kong v0.7.1/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U=
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

0 comments on commit bf34e54

Please sign in to comment.