Add a more helpful error message when unkown options are encountered#65
Open
caldwell wants to merge 1 commit intodocopt:masterfrom
Open
Add a more helpful error message when unkown options are encountered#65caldwell wants to merge 1 commit intodocopt:masterfrom
caldwell wants to merge 1 commit intodocopt:masterfrom
Conversation
|
I just ran into this, so now my and my go file looks like this: package main
import (
docopt "github.com/caldwell/docopt.go"
) |
artburkart
reviewed
Jul 16, 2019
| for _, l := range(*left) { | ||
| left_names = append(left_names, l.name) | ||
| } | ||
| err = newUserError(fmt.Sprintf("Unknown option(s): %s", strings.Join(left_names, ", "))) |
There was a problem hiding this comment.
@caldwell - I believe golint will complain about this error message because the first letter is capitalized.
https://github.com/golang/go/wiki/CodeReviewComments#error-strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When there is a bad option, docopt-go silently prints the usage and gives no indication of which option(s) it didn't like. It's very confusing when a program with a lot of options has a command line with one of them misspelled.
This patch complains about unknown options instead of silently printing the usage.