Skip to main content

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

  • QCommand is abstract: subclasses must call super(name, description) and implement _run.
  • CommandStore.register(...) instantiates each command class once and indexes it by commandName.
  • CommandStore.execute(name, args) runs a registered command programmatically (used in tests) and throws MissingCommandError if the name isn't registered.