Open MercatoDocsSearch docsAPI reference

CLI

CLI Overview

Use the CLI to set up a workspace, apply migrations and administer modules from a terminal. Select the command that matches the app and workspace you are working in.

Open Mercato bundles CLI commands for project setup, tenant administration, and module scaffolding. Top-level helpers are exposed as Yarn scripts (yarn initialize, yarn db:generate, …) while module-specific utilities live under the umbrella command:

yarn mercato <module> <command> [options]

Run yarn mercato --help to list modules and yarn mercato <module> --help to drill in.

Asking for Help Never Runs the Command

--help and -h are answered by the dispatcher before the command is invoked, at every level:

yarn mercato --help                  # list modules
yarn mercato db --help               # list the db module's commands
yarn mercato db generate --help      # print usage for one command — generates nothing

A help invocation is always a no-op: it never runs the command it is asking about, and it never creates .env from .env.example. This matters most for the destructive commands – yarn mercato db migrate --help describes the command instead of applying every pending migration.

Documenting Your Own Module Commands

A ModuleCli descriptor in your module's cli.ts – the same shape mercato module add registers for you – takes two optional fields that control this behavior:

import type { ModuleCli } from '@open-mercato/shared/modules/registry'

const cli: ModuleCli[] = [
  {
    command: 'sync',
    help: 'Usage: mercato inventory sync [--since <iso-date>]\nPulls stock levels from the configured provider.',
    run: async (argv) => { /* … */ },
  },
]

export default cli

Workflow Cheat Sheet

Each linked page provides usage syntax, option breakdowns, sample output, and troubleshooting notes so you can copy commands directly into your terminal.

Previous: mercato module search · Next: Scheduler CLI