CLI Plugins
Plugins can add custom CLI commands.
Adding a CLI Command
import type { BlockPlugin } from "org-press";
export const myPlugin: BlockPlugin = {
name: "my-plugin",
cli: {
command: "mycommand",
description: "Do something useful",
options: [
{ flag: "-o, --output <dir>", description: "Output directory" },
{ flag: "-v, --verbose", description: "Verbose output" },
],
action: async (args, config, plugins) => {
console.log("Running mycommand");
console.log("Args:", args);
console.log("Config:", config);
},
},
};
CLI Interface
interface CliCommand {
/** Command name (e.g., "test", "fmt") */
command: string;
/** Description for --help */
description: string;
/** Command options */
options?: CliOption[];
/** Command implementation */
action: (
args: Record<string, any>,
config: OrgPressConfig,
plugins: BlockPlugin[]
) => Promise<void>;
}
interface CliOption {
flag: string; // e.g., "-o, --output <dir>"
description: string;
default?: any;
}
Built-in CLI Commands
These are implemented as CLI plugins:
orgp fmt- Format code blocksorgp lint- Lint code blocksorgp type-check- Type-check TypeScriptorgp test- Run tests (via @org-press/block-test)
Example: Test Plugin CLI
export const testPlugin: BlockPlugin = {
name: "test",
cli: {
command: "test",
description: "Run tests in :use test blocks",
options: [
{ flag: "--watch", description: "Watch mode" },
{ flag: "--coverage", description: "Collect coverage" },
],
action: async (args) => {
// Run vitest with collected test blocks
},
},
};