Skip to content

CLI API

@grain.sh/cli gives Grain a terminal surface. It is useful for local validation, automation output, and reviewing Grain documents without building a browser UI first.


CLIAdapter

typescript
import { CLIAdapter } from '@grain.sh/cli';

const adapter = new CLIAdapter(options);

What To Use It For

  • inspect Grain output during development
  • render saved .glang fixtures in CI or local automation
  • debug parser and state-machine behavior in a terminal-first workflow

Options

typescript
interface CLIOptions {
  theme?: 'light' | 'dark';
}

Methods

render()

typescript
adapter.render(grain: string): string

CLI Binary

bash
grain [options]

Options

OptionDescription
--input, -iInput file
--output, -oOutput file
--watch, -wWatch mode
--themeTheme (light/dark)

Operational Notes

  • The grain executable is the canonical binary name.
  • Watch mode should be used against a real file path so content changes are re-read from disk.
  • For contract debugging, pair the CLI with @grain.sh/core tests or parser fixtures.

Released under the MIT License.