[adonisjs 5.0] create ace command examples? #1539
-
Hi, I'm new to adonisjs. I want to create a new ace command, but from the help doc, I can only see the doc of adonisjs 4.0. The signature of ace command has changed and I don't know how to use the args and flags. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yup. The docs are missing on same. So lemme try to explain it here. Following command creates a new command for you node ace make:command <NAME> The empty command class has 3 properties import { BaseCommand } from '@adonisjs/ace'
export default class YourCommandName extends BaseCommand {
public static commandName = 'commandName'
public static description = 'Description'
public async handle() {
}
} The You can accept flags using the You can accept arguments using the |
Beta Was this translation helpful? Give feedback.
Yup. The docs are missing on same. So lemme try to explain it here.
Following command creates a new command for you
The empty command class has 3 properties
The
commandName
anddescription
is for the help screen. Thehandle
method is called when your command is executed.You can accept flags using the
@flags
decorator. Here's an example: https://github.com/adonisjs/core/blob/develop/commands/ListRoutes.ts#L22-L23You can accept arguments using…