Skip to main content

Module CLI commands

Modules can register custom CLI commands that are automatically discovered and made available through the saasframe CLI. This allows you to extend the CLI with module-specific functionality.

How it works

  1. Create a cli/ directory in your module (e.g., packages/<pkg>/src/modules/<module>/cli/)
  2. Export command handlers following the CLI command structure
  3. Run yarn generate to update the CLI registry
  4. Your commands become available as yarn saasframe <module> <command>

Example: Creating a custom CLI command

packages/inventory/src/modules/inventory/cli/sync.ts
import type { CliCommandHandler } from '@saasframe/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 saasframe inventory sync

Verifying CLI registration

If your command does not appear, ensure:

  1. yarn generate has been run after adding the command
  2. The module is enabled in apps/saasframe/src/modules.ts
  3. The command file exports both metadata and a default handler function

For more details on CLI command structure, see the CLI development guide.