⚠️Early Alpha — Org-press is experimental. Perfect for hackers and tinkerers, not ready for production. Documentation may be incomplete or inaccurate.

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 blocks
  • orgp lint - Lint code blocks
  • orgp type-check - Type-check TypeScript
  • orgp 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
    },
  },
};