CLI Commands
The LUMOS CLI (lumos) provides four main commands for working with .lumos schema files.
Installation
Section titled “Installation”cargo install lumos-cliVerify installation:
lumos --version# Output: lumos-cli 0.1.0lumos generate
Section titled “lumos generate”Generate Rust and TypeScript code from a .lumos schema file.
lumos generate <SCHEMA_FILE> [OPTIONS]Arguments
Section titled “Arguments”<SCHEMA_FILE>- Path to the.lumosschema file (required)
Options
Section titled “Options”| Option | Short | Description | Default |
|---|---|---|---|
--output-dir | -o | Output directory for generated files | Current directory |
--rust-file | Custom name for Rust output | generated.rs | |
--typescript-file | Custom name for TypeScript output | generated.ts | |
--format | -f | Format output with rustfmt/prettier | true |
--help | -h | Print help information | - |
Examples
Section titled “Examples”Basic generation:
lumos generate schema.lumosGenerates:
./generated.rs- Rust structs and enums./generated.ts- TypeScript interfaces + Borsh schemas
Custom output directory:
lumos generate schema.lumos --output-dir ./src/generatedCustom file names:
lumos generate schema.lumos \\ --rust-file types.rs \\ --typescript-file types.tsSkip formatting:
lumos generate schema.lumos --no-formatExit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| 0 | Success - files generated |
| 1 | Parse error - invalid .lumos syntax |
| 2 | Transform error - unsupported types or attributes |
| 3 | I/O error - cannot write files |
Common Errors
Section titled “Common Errors”File not found:
Error: Schema file not found: schema.lumosFix: Check file path is correct.
Parse error:
Error: Failed to parse schema --> schema.lumos:5:12 |5 | level u16, | ^ expected ':'Fix: Add : after field name (level: u16).
Invalid type:
Error: Unsupported type 'f64' at line 10Fix: Use supported types only. See Type System.
lumos validate
Section titled “lumos validate”Check if a .lumos schema file has valid syntax.
lumos validate <SCHEMA_FILE>Arguments
Section titled “Arguments”<SCHEMA_FILE>- Path to the.lumosschema file (required)
Examples
Section titled “Examples”Valid schema:
lumos validate schema.lumos# Output: ✓ Schema is valid# Exit code: 0Invalid schema:
lumos validate bad_schema.lumos# Output:# Error: Failed to parse schema# --> bad_schema.lumos:3:5# |# 3 | invalid syntax here# | ^^^^^^^ unexpected token# Exit code: 1Use Cases
Section titled “Use Cases”- Pre-commit hook - Validate before committing
- CI/CD pipeline - Ensure schemas are valid
- Editor integration - Real-time syntax checking
Example: Pre-commit Hook
Section titled “Example: Pre-commit Hook”#!/bin/bash# Find all .lumos filesLUMOS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\\.lumos$')
if [ -n "$LUMOS_FILES" ]; then for file in $LUMOS_FILES; do lumos validate "$file" if [ $? -ne 0 ]; then echo "❌ Validation failed for $file" exit 1 fi done echo "✅ All schemas valid"filumos init
Section titled “lumos init”Initialize a new LUMOS project with example schema and configuration.
lumos init [PROJECT_NAME]Arguments
Section titled “Arguments”[PROJECT_NAME]- Optional directory name (defaults to current directory)
Examples
Section titled “Examples”Create new project:
lumos init my-solana-appcd my-solana-appInitialize current directory:
mkdir my-project && cd my-projectlumos initGenerated Files
Section titled “Generated Files”my-solana-app/├── schema.lumos # Example schema├── lumos.toml # Configuration file└── README.md # Getting started guideschema.lumos (example):
#[solana]#[account]struct PlayerAccount { wallet: PublicKey, level: u16, experience: u64,}lumos.toml (configuration):
[generation]rust_output = "generated.rs"typescript_output = "generated.ts"format = true
[imports]rust_prelude = truelumos check
Section titled “lumos check”Verify that generated code is up-to-date with schema.
lumos check <SCHEMA_FILE>Arguments
Section titled “Arguments”<SCHEMA_FILE>- Path to the.lumosschema file (required)
Examples
Section titled “Examples”Schema and generated files match:
lumos check schema.lumos# Output: ✓ Generated files are up-to-date# Exit code: 0Schema changed, need regeneration:
lumos check schema.lumos# Output: ⚠️ Generated files are outdated# Run: lumos generate schema.lumos# Exit code: 1Generated files missing:
lumos check schema.lumos# Output: ⚠️ Generated files not found# Run: lumos generate schema.lumos# Exit code: 1Use Cases
Section titled “Use Cases”- CI/CD Pipeline - Ensure developers ran
generatebefore committing - Build Scripts - Automatically regenerate if needed
- Pre-build Hook - Verify code is current
Example: package.json Script
Section titled “Example: package.json Script”{ "scripts": { "prebuild": "lumos check schema.lumos || lumos generate schema.lumos", "build": "anchor build" }}Example: GitHub Actions
Section titled “Example: GitHub Actions”name: Check LUMOS Schemas
on: [push, pull_request]
jobs: check-schemas: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Install LUMOS CLI run: cargo install lumos-cli
- name: Check schemas are up-to-date run: | for schema in $(find . -name "*.lumos"); do lumos check "$schema" doneGlobal Options
Section titled “Global Options”Available for all commands:
| Option | Short | Description |
|---|---|---|
--help | -h | Print help information |
--version | -V | Print version information |
--verbose | -v | Enable verbose output |
--quiet | -q | Suppress non-error output |
Examples
Section titled “Examples”Verbose mode:
lumos generate schema.lumos -v# Output:# [DEBUG] Parsing schema file...# [DEBUG] Transforming AST to IR...# [DEBUG] Generating Rust code...# [DEBUG] Generating TypeScript code...# ✓ Generated 2 filesQuiet mode:
lumos generate schema.lumos -q# No output on success, only errorsEnvironment Variables
Section titled “Environment Variables”Configure LUMOS CLI behavior via environment variables:
| Variable | Description | Default |
|---|---|---|
LUMOS_OUTPUT_DIR | Default output directory | Current directory |
LUMOS_FORMAT | Enable/disable formatting | true |
LUMOS_COLOR | Enable/disable colored output | Auto-detect |
Examples
Section titled “Examples”# Disable colored outputexport LUMOS_COLOR=neverlumos generate schema.lumos
# Change default output directoryexport LUMOS_OUTPUT_DIR=./generatedlumos generate schema.lumosExit Status Summary
Section titled “Exit Status Summary”| Code | Meaning | Commands |
|---|---|---|
| 0 | Success | All |
| 1 | Parse/validation error | generate, validate, check |
| 2 | Transform error | generate |
| 3 | I/O error | generate, init |
| 4 | Outdated files | check |
Tips & Best Practices
Section titled “Tips & Best Practices”See Also
Section titled “See Also”- Type System - Supported types and mappings
- Attributes - Available schema attributes
- Generated Code - Understanding output