-
-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Description
Issue Type
- Bug Report
- Feature Request
- Other
Hi. I am attempting to create my first Node.js CLI program.
const cli = cac("sample-app");
cli.command("hello", "say hello world").action(() => {
console.log("Hello World!");
});
const parsed = cli.parse();
console.log(parsed);I ran this sample code using the npx vite-node index.ts hello command.
Expected
"Hello World!" is being printed.
Actual
"Hello World!" is not being printed.There are no errors.The help() and version() commands are working as expected.
Possible Solutions
Upon investigation, I found that using parse(process.argv) results in "Hello World!" being printed when no arguments are provided, while the parsed object logged in both cases shows the differences:
No arguments provided (incorrect)
{ args: [ 'index.ts', 'hello' ], options: { '--': [] } }
Using process.argv as arguments (correct)
{ args: [], options: { '--': [] } }
It appears that the code processes arguments differently when no arguments are provided, and it seems to be related to Deno's Deno.args.
I'm not familiar with Deno, so this difference is a puzzling.
Info
- CAC version: 6.7.14
- Reproduction link:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels