Skip to content

Commit

Permalink
Show usage on error
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Jun 18, 2024
1 parent f187810 commit 2ff7fad
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ func main() {
User UserCmd `cmd:"" help:"Info about current user. e.g. \"is user sudoer\""`
Version kong.VersionFlag `help:"Print version to screen"`

InstallCompletions kongplete.InstallCompletions `cmd:"" help:"install shell completions. e.g. \"is install-completions\" and then run the command which is printed to your terminal"`
InstallCompletions kongplete.InstallCompletions `cmd:"" help:"install shell completions. e.g. \"is install-completions\" and then run the command which is printed to your terminal"` //nolint:lll
}

parser := kong.Must(&API,
kong.Name("is"),
kong.Description("A shell-like example app."),
kong.UsageOnError(),
kong.Vars{"version": "0.5.0"},
)

// Run kongplete.Complete to handle completion requests
kongplete.Complete(parser,
kongplete.WithPredictor("file", complete.PredictFiles("*")),
)

ctx := kong.Parse(&API,
kong.Vars{
"version": "0.5.0",
})
ctx, err := parser.Parse(os.Args[1:])
parser.FatalIfErrorf(err)

runContext := types.Context{Debug: API.Debug}
err := ctx.Run(&runContext)
err = ctx.Run(&runContext)
ctx.FatalIfErrorf(err)

if runContext.Success {
Expand Down

0 comments on commit 2ff7fad

Please sign in to comment.