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

Improve help text when invalid arguments are given #4176

Merged
merged 5 commits into from
Apr 19, 2018
Merged

Conversation

nickethier
Copy link
Member

@nickethier nickethier commented Apr 18, 2018

image

@@ -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)) {
Copy link
Member

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())
}
Copy link
Member

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.

@schmichael
Copy link
Member

Looks like one of those test failures is relevant: https://travis-ci.org/hashicorp/nomad/jobs/368271509#L2645

@nickethier nickethier merged commit 73b94f5 into master Apr 19, 2018
@nickethier nickethier deleted the i-cli-error-help branch April 19, 2018 16:46
nickethier added a commit that referenced this pull request Apr 25, 2018
nickethier added a commit that referenced this pull request Apr 25, 2018
@github-actions
Copy link

github-actions bot commented Mar 6, 2023

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants