Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to example tools #465

Merged
merged 1 commit into from
May 18, 2019
Merged

Fixes to example tools #465

merged 1 commit into from
May 18, 2019

Conversation

wallyqs
Copy link
Member

@wallyqs wallyqs commented May 17, 2019

Apply similar fix as #456 and call exit 1 after showing the tool usage/help message.
Signed-off-by: Waldemar Quevedo [email protected]

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 means success, and 1 means a failure. Do we want Exit(0) here? @kozlovic any opinion?

@wallyqs
Copy link
Member Author

wallyqs commented May 17, 2019

I think we should exit 0 at least in the case for when only showing help, then exit 1 on incorrect usage. I could add an showUsageAndDie function for that for example, then exit 0 when only showing help.

@derekcollison
Copy link
Member

ok I agree.

@wallyqs wallyqs force-pushed the example-tool-fixes branch 2 times, most recently from 7cb28c8 to a6206ce Compare May 17, 2019 20:26
@wallyqs
Copy link
Member Author

wallyqs commented May 17, 2019

Applied updates to the tools so that:

  • -h is exit 0
  • wrong usage, is exit 1
  • wrong/unknown flags and arguments is exit 2

@@ -37,6 +37,10 @@ const (
func usage() {
log.Printf("Usage: nats-bench [-s server (%s)] [--tls] [-np NUM_PUBLISHERS] [-ns NUM_SUBSCRIBERS] [-n NUM_MSGS] [-ms MESSAGE_SIZE] [-csv csvfile] <subject>\n", nats.DefaultURL)
flag.PrintDefaults()
}

func showUsageAndDie() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe ShowUsageAndExit(exitcode int)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me, just updated

Signed-off-by: Waldemar Quevedo <[email protected]>
@wallyqs wallyqs force-pushed the example-tool-fixes branch from a6206ce to eabeb89 Compare May 17, 2019 20:58
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekcollison derekcollison merged commit 01af1f9 into master May 18, 2019
@derekcollison derekcollison deleted the example-tool-fixes branch May 18, 2019 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants