CLI
Expose a module-specific operation in the CLI by registering a command handler. The small greeting example shows the registration path before you add business logic.
Modules can register custom CLI commands that are automatically discovered and made available through the mercato CLI. This allows you to extend the CLI with module-specific functionality.
cli/ directory in your module (e.g., packages/<pkg>/src/modules/<module>/cli/)yarn generate to update the CLI registryyarn mercato <module> <command>import type { CliCommandHandler } from '@open-mercato/shared/cli';
export const metadata = {
command: 'sync',
description: 'Synchronize inventory data from external sources',
};
export default async function handler(args: string[], ctx: CliContext) {
console.log('Syncing inventory...');
// Your sync logic here
}
After running yarn generate, the command becomes available:
yarn mercato inventory sync
If your command does not appear, ensure:
yarn generate has been run after adding the commandapps/mercato/src/modules.tsmetadata and a default handler functionFor more details on CLI command structure, see the CLI development guide.
Previous: mercato entities install · Next: mercato example seed-todos