-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Strange API behaviour for command description #2290
Comments
Sorry you hit this problem. This used to be a common source of confusion: #938 The README was updated to mention the behaviour. In particular in the example code in the Commands section: https://github.com/tj/commander.js?tab=readme-ov-file#commands Lines 519 to 541 in 970ecae
And in the section: https://github.com/tj/commander.js?tab=readme-ov-file#stand-alone-executable-subcommands
There is also a message explaining the possible problem if a missing external command is detected at runtime, but you didn't see that. I suspect a different error may be getting thrown on Windows or in recent versions of node. I'll look into that. Line 1222 in 970ecae
|
Running your example program, I see this on macOS: % node index.mjs analyze
/Users/john/Documents/Sandpits/commander/my-fork/lib/command.js:1234
throw new Error(executableMissing);
^
Error: 'index-analyze' does not exist
- if 'analyze' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
- searched for local subcommand relative to directory '/Users/john/Documents/Sandpits/commander/issues/2290'
... |
Ah, the way the stand-alone executable commands get launched varies by platform, and the Windows code path does not trigger the extra message. I think we can improve that by checking for the file before spawning the process. Line 1183 in 970ecae
|
When adding description to command declaration, command does not work.
Working code:
Execute:
Not working code:
Execute:
I spent HOURS to find a way to make commander work for simpliest command. Read all docummentation, tried several versions, and only happy accident helped me - I added description for one command, and do not added to another. So I found, that another command working and this give me a tip.
I think, when description specified, or command options specified, commander begin interpretate it as executable command. If it is true, then action() should throw error - it is usless for executable command. WTF? Why simple adding description change behaviour totally? And where in documentation this behaviour is specified?
The text was updated successfully, but these errors were encountered: