-
-
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
Passing description to the "command()" method causes error being produced in runtime #976
Comments
It is a common cause of confusion. Added this issue to #938. |
I have same problem, when I try to attach a desc text to command, It's not work.
program
|> command("cc <dir>"/*, "Compile pattern to docker compose config"*/)
/* |> description("Compile pattern to docker compose config") */
/* |> alias("cc") */
|> option("-o, --output", "Output dir")
|> action(Cmd_Cc.main); coding with reasonml now 😹 |
FYI @andares (and I think @slavafomin worked this out after getting caught out by the current behaviour). For action based command handling you pass the description separately from the command:
For git-style executables you pass the description along with the command:
|
if set description with command() function: var Process = require("process");
var Commander = require("commander");
var program = Commander.version("0.1.0");
program.allowUnknownOption(false);
program.command("cc <dir>", "Compile pattern to docker compose config").option("-o, --output", "Output dir").action((function (param) {
console.log("test");
return /* () */0;
}));
program.parse(Process.argv); there has problem when run:
|
@andares I fixed my comment with examples where I had a mistake, hopefully clearer now! (Sorry.) |
I got it, thanks 😄 |
This issue will be resolved when v3.0.0 is released. Available now as a prerelease. See #1001 Reworked the README and JSDoc and TypeScript to hopefully make the two modes of operation clearer. Have not changed the runtime, but will close this issue and see how the changes help. |
Reworked the README and JSDoc and TypeScript to hopefully make the two modes of operation clearer. Have not changed the runtime, but will close this issue and see how the changes help. Shipped in v3: https://github.com/tj/commander.js/releases/tag/v3.0.0 |
Hello!
Thank you for this great library!
However, when command description is passed as a second argument to the
Command.command()
method it causes the following error in runtimeerror: foo-bar(1) does not exist, try --help
.This doesn't work:
But this works:
This is extremely counter-intuitive, especially when you explore the API using IDE autocompletion. When I see the
description
argument of the method, my first thought it to pass it to it.Having two methods of passing the description with one of them triggering some different behavior looks pretty insane from the API standpoint.
The text was updated successfully, but these errors were encountered: