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 error messaging when more args than expected are passed. #906



Copy link

@andrewsomething andrewsomething commented Oct 29, 2020

When a user provides multiple arguments to a command then only accepts one, we provide unclear error messaging. For example:

$ doctl databases sql-mode get aaa-bbb-ccc ddd-eee-fff
Error: (sql-mode.get) command is missing required arguments

This PR adds a new helper method, ensureOneArg, that returns a MissingArgsErr if no args are passed or a TooManyArgsErr (introduced in #902) if more than one is passed. This allows for clearer messaging:

$ ./builds/doctl databases sql-mode get aaa-bbb-ccc ddd-eee-fff
Error: (sql-mode.get) command contains unsupported arguments

$ ./builds/doctl databases sql-mode get
Error: (sql-mode.get) command is missing required arguments

Copy link

@bentranter bentranter left a comment

Looks good (once Travis passes in about two weeks 😴)

@andrewsomething andrewsomething merged commit 6c0d19a into digitalocean:master Oct 29, 2020
3 checks passed
@andrewsomething andrewsomething deleted the asb/ensure-one-arg branch Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants