Skip to content

CLI Commands

The LUMOS CLI (lumos) provides four main commands for working with .lumos schema files.

Terminal window
cargo install lumos-cli

Verify installation:

Terminal window
lumos --version
# Output: lumos-cli 0.1.0

Generate Rust and TypeScript code from a .lumos schema file.

Terminal window
lumos generate <SCHEMA_FILE> [OPTIONS]
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)
OptionShortDescriptionDefault
--output-dir-oOutput directory for generated filesCurrent directory
--rust-fileCustom name for Rust outputgenerated.rs
--typescript-fileCustom name for TypeScript outputgenerated.ts
--format-fFormat output with rustfmt/prettiertrue
--help-hPrint help information-

Basic generation:

Terminal window
lumos generate schema.lumos

Generates:

  • ./generated.rs - Rust structs and enums
  • ./generated.ts - TypeScript interfaces + Borsh schemas

Custom output directory:

Terminal window
lumos generate schema.lumos --output-dir ./src/generated

Custom file names:

Terminal window
lumos generate schema.lumos \\
--rust-file types.rs \\
--typescript-file types.ts

Skip formatting:

Terminal window
lumos generate schema.lumos --no-format
CodeMeaning
0Success - files generated
1Parse error - invalid .lumos syntax
2Transform error - unsupported types or attributes
3I/O error - cannot write files

File not found:

Error: Schema file not found: schema.lumos

Fix: 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 10

Fix: Use supported types only. See Type System.


Check if a .lumos schema file has valid syntax.

Terminal window
lumos validate <SCHEMA_FILE>
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)

Valid schema:

Terminal window
lumos validate schema.lumos
# Output: ✓ Schema is valid
# Exit code: 0

Invalid schema:

Terminal window
lumos validate bad_schema.lumos
# Output:
# Error: Failed to parse schema
# --> bad_schema.lumos:3:5
# |
# 3 | invalid syntax here
# | ^^^^^^^ unexpected token
# Exit code: 1
  1. Pre-commit hook - Validate before committing
  2. CI/CD pipeline - Ensure schemas are valid
  3. Editor integration - Real-time syntax checking
.git/hooks/pre-commit
#!/bin/bash
# Find all .lumos files
LUMOS_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"
fi

Initialize a new LUMOS project with example schema and configuration.

Terminal window
lumos init [PROJECT_NAME]
  • [PROJECT_NAME] - Optional directory name (defaults to current directory)

Create new project:

Terminal window
lumos init my-solana-app
cd my-solana-app

Initialize current directory:

Terminal window
mkdir my-project && cd my-project
lumos init
my-solana-app/
├── schema.lumos # Example schema
├── lumos.toml # Configuration file
└── README.md # Getting started guide

schema.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 = true

Verify that generated code is up-to-date with schema.

Terminal window
lumos check <SCHEMA_FILE>
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)

Schema and generated files match:

Terminal window
lumos check schema.lumos
# Output: ✓ Generated files are up-to-date
# Exit code: 0

Schema changed, need regeneration:

Terminal window
lumos check schema.lumos
# Output: ⚠️ Generated files are outdated
# Run: lumos generate schema.lumos
# Exit code: 1

Generated files missing:

Terminal window
lumos check schema.lumos
# Output: ⚠️ Generated files not found
# Run: lumos generate schema.lumos
# Exit code: 1
  1. CI/CD Pipeline - Ensure developers ran generate before committing
  2. Build Scripts - Automatically regenerate if needed
  3. Pre-build Hook - Verify code is current
{
"scripts": {
"prebuild": "lumos check schema.lumos || lumos generate schema.lumos",
"build": "anchor build"
}
}
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"
done

Available for all commands:

OptionShortDescription
--help-hPrint help information
--version-VPrint version information
--verbose-vEnable verbose output
--quiet-qSuppress non-error output

Verbose mode:

Terminal window
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 files

Quiet mode:

Terminal window
lumos generate schema.lumos -q
# No output on success, only errors

Configure LUMOS CLI behavior via environment variables:

VariableDescriptionDefault
LUMOS_OUTPUT_DIRDefault output directoryCurrent directory
LUMOS_FORMATEnable/disable formattingtrue
LUMOS_COLOREnable/disable colored outputAuto-detect
Terminal window
# Disable colored output
export LUMOS_COLOR=never
lumos generate schema.lumos
# Change default output directory
export LUMOS_OUTPUT_DIR=./generated
lumos generate schema.lumos

CodeMeaningCommands
0SuccessAll
1Parse/validation errorgenerate, validate, check
2Transform errorgenerate
3I/O errorgenerate, init
4Outdated filescheck