We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
--help
13.3.0
Hello,
I am trying to use ace to build a cli tool outside of Adonis. Inspired by the toolkit command I wrote the following code:
ace
import "reflect-metadata"; import { BaseCommand, args, Kernel, ListLoader, HelpCommand } from "@adonisjs/ace"; class Demo extends BaseCommand { public static commandName = "demo"; @args.string({ description: "first arg" }) declare first_arg: string; @args.string({ description: "second arg" }) declare second_arg: string; public async run() { this.logger.info(`Hello from demo command`); } } const kernel = Kernel.create(); kernel.addLoader(new ListLoader([Demo])); kernel.defineFlag("help", { type: "boolean", description: HelpCommand.description, }); kernel.on("help", async (command, $kernel, parsed) => { parsed.args.unshift(command.commandName); const help = new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt); await help.exec(); return $kernel.shortcircuit(); }); await kernel.handle(process.argv.splice(2));
My understanding is that this part makes the flag --help available for all commands:
kernel.defineFlag("help", { type: "boolean", description: HelpCommand.description, }); kernel.on("help", async (command, $kernel, parsed) => { parsed.args.unshift(command.commandName); const help = new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt); await help.exec(); return $kernel.shortcircuit(); });
However, when I run node --import tsx main.ts demo --help I get the following error:
node --import tsx main.ts demo --help
Usage: demo <first-arg> <second-arg> Arguments: first-arg first arg second-arg second arg ERROR Missing required argument "second_arg"
Note the error at the end of the output.
This only happens when my Demo command has more than one argument.
Demo
Am I doing something wrong here?
https://github.com/webNeat/adonis-ace-bug
The text was updated successfully, but these errors were encountered:
Yup, it indeed looks like a bug. Ideally this line of code https://github.com/adonisjs/ace/blob/13.x/src/kernel.ts#L335 should be after the shortcircuit conditional but no idea why I have put it before it.
shortcircuit
Lemme run some tests and then push a fix
Sorry, something went wrong.
thetutlage
No branches or pull requests
Package version
13.3.0
Describe the bug
Hello,
I am trying to use
ace
to build a cli tool outside of Adonis. Inspired by the toolkit command I wrote the following code:My understanding is that this part makes the flag
--help
available for all commands:However, when I run
node --import tsx main.ts demo --help
I get the following error:Note the error at the end of the output.
This only happens when my
Demo
command has more than one argument.Am I doing something wrong here?
Reproduction repo
https://github.com/webNeat/adonis-ace-bug
The text was updated successfully, but these errors were encountered: