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
- Create a
cli/directory in your module (e.g.,packages/<pkg>/src/modules/<module>/cli/) - Export command handlers following the CLI command structure
- Run
yarn generateto update the CLI registry - 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:
yarn generatehas been run after adding the command- The module is enabled in
apps/saasframe/src/modules.ts - The command file exports both
metadataand a default handler function
For more details on CLI command structure, see the CLI development guide.