Skip to content

Error out if unknown command#896

Closed
freemany wants to merge 5 commits intotj:masterfrom
freemany:master
Closed

Error out if unknown command#896
freemany wants to merge 5 commits intotj:masterfrom
freemany:master

Conversation

@freemany
Copy link
Copy Markdown

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.

@segfaultmedaddy
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

See also: #941

@shadowspawn
Copy link
Copy Markdown
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
Copy Markdown
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.

3 participants