Skip to content

Commit

Permalink
Merge pull request choria-io#101 from ripienaar/100
Browse files Browse the repository at this point in the history
(choria-io#100) improve usage output
  • Loading branch information
ripienaar authored Dec 22, 2022
2 parents a106653 + 60db01f commit e6884cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ajc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func main() {
ajc.Version(version)
ajc.Author("R.I.Pienaar <[email protected]>")
ajc.UsageWriter(os.Stdout)
ajc.UsageTemplate(fisk.CompactUsageTemplate)
ajc.UsageTemplate(fisk.CompactMainUsageTemplate)
ajc.ErrorUsageTemplate(fisk.CompactMainUsageTemplate)
ajc.HelpFlag.Short('h')

ajc.Flag("context", "NATS Context to use for connecting to JetStream").PlaceHolder("NAME").Envar("CONTEXT").Default("AJC").StringVar(&nctx)
Expand All @@ -46,9 +47,6 @@ func main() {
_, err := ajc.Parse(os.Args[1:])
if err != nil {
switch {
case strings.Contains(err.Error(), "expected command but"):
ajc.Usage(nil)

case strings.Contains(err.Error(), "unknown context"):
fmt.Fprintf(os.Stderr, "ajc: no NATS context %q found, create one using 'nats context'\n", nctx)

Expand All @@ -60,6 +58,8 @@ func main() {

default:
fmt.Fprintf(os.Stderr, "ajc runtime error: %v\n", err)
fmt.Fprintln(os.Stderr)
ajc.Usage(os.Args[1:])
}

os.Exit(1)
Expand Down

0 comments on commit e6884cb

Please sign in to comment.