Quickstart
Run the built-in commands from the quik executable:
quik config:print --format pretty
quik config:generate --out-dir src/config --merge
quik crypto:app-key:generate
quik module:create Billing --out-dir src/modules
Writing a custom command
import { getConfig } from '@quik/core';
import type { ArgumentsCamelCase } from 'yargs';
import { QCommand, CommandStore } from '@quik/cli';
type PingArgs = { verbose?: boolean };
class PingCommand extends QCommand<PingArgs> {
public constructor() {
super('ping', 'Check that the CLI is wired up.');
this.pushOptions('verbose', { type: 'boolean', default: false, describe: 'Print extra output.' });
}
protected async _run(args: ArgumentsCamelCase<PingArgs>): Promise<void> {
process.stdout.write(args.verbose ? `pong (${getConfig().string('app.name', 'app')})\n` : 'pong\n');
}
}
CommandStore.register(PingCommand);
Notes
QCommandis abstract: subclasses must callsuper(name, description)and implement_run.CommandStore.register(...)instantiates each command class once and indexes it bycommandName.CommandStore.execute(name, args)runs a registered command programmatically (used in tests) and throwsMissingCommandErrorif the name isn't registered.