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

Error out if unknown command #896

Closed
wants to merge 5 commits into from
Closed

Error out if unknown command #896

wants to merge 5 commits into from

Conversation

freemany
Copy link

If we have commands foo bar coo, once you type with unknown subcommand such as:
$ foo invalid
it will output error ''Error: unknown command invalid' with help info.

$ foo bar invalid
it will output error ''Error: unknown command invalid' with help info.

Tests are added.

@roman-vanesyan
Copy link
Collaborator

Thank for a pr, unfortunately, we cannot accept it this time, as it introduces a breaking change, will we come back to it once work on v3 will be started.

@shadowspawn shadowspawn self-requested a review May 13, 2019 10:20
@shadowspawn
Copy link
Collaborator

Lots of little comments from first read through:

  • there are some requests for this in open issues, adding references to issues this resolves is helpful for reviewing
  • musing: I wonder if the historical lack of warning is for simple case where user only processing options and does command detection themselves
  • I was bit surprised to see explicit test for NODE_ENV, wondering if this is avoidable with sinon
  • there are a number of additions of descriptions to tests. What is the reason for that?
  • nice to see tests around the new behaviour (thanks)

@shadowspawn
Copy link
Collaborator

See also: #941

@shadowspawn
Copy link
Collaborator

I am leaving this one out of v3 as the error handling is quite subtle and fragile, and this Pull Request changed quite a lot of files. Keeping open, but no action likely in meantime.

@shadowspawn shadowspawn removed their request for review June 22, 2019 05:04
@shadowspawn
Copy link
Collaborator

I would like to offer easy handling of unknown commands, because I expect most people would like it. However, there will also be people who have written fancy suggestions for misspellings, or be relying on processing themselves, so might need a way to opt-out.

Changes to the error detection and handling are hard, with lots of code paths for .action and git-style executables, programs with and without .argument, default commands, et al.

This PR incorrectly generates error messages when the program has .arguments.

Adding support for automatic detection of unknown commands is likely to be quite a big job, or require quite a bit of analysis of use cases. Or both!

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.

None yet

3 participants