-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Improve help text when invalid arguments are given #4176
Conversation
nickethier
commented
Apr 18, 2018
•
edited by schmichael
Loading
edited by schmichael
@@ -21,7 +21,7 @@ func TestDeploymentListCommand_Fails(t *testing.T) { | |||
if code := cmd.Run([]string{"some", "bad", "args"}); code != 1 { | |||
t.Fatalf("expected exit code 1, got: %d", code) | |||
} | |||
if out := ui.ErrorWriter.String(); !strings.Contains(out, cmd.Help()) { | |||
if out := ui.ErrorWriter.String(); !strings.Contains(out, commandErrorText(cmd)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future you can switch this style of check to use https://godoc.org/github.com/stretchr/testify/require#Contains and save a couple lines. No need to go back through and change all of these though.
// when an error is printed. | ||
func commandErrorText(cmd NamedCommand) string { | ||
return fmt.Sprintf("For additional help try 'nomad %s -help'", cmd.Name()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the little helper func + utility interface.
Looks like one of those test failures is relevant: https://travis-ci.org/hashicorp/nomad/jobs/368271509#L2645 |
CHANGELOG: add line for #4176
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |