Compiler Commands
Reference for all msc (MetaScript Compiler) commands.
Global Options
These options work with all commands:
msc [command] [options]
Options:
-h, --help Show help
-v, --version Show version number
-q, --quiet Suppress non-error output
--verbose Show detailed output
--color Force colored output
--no-color Disable colored outputCommands
msc build
Compile MetaScript to the target backend.
msc build [entry] [options]Arguments:
| Argument | Description | Default |
|---|---|---|
entry | Entry file or directory | src/ |
Options:
| Option | Description | Default |
|---|---|---|
-t, --target | Compilation target (js, c, erlang) | js |
-o, --outDir | Output directory | dist/ |
--release | Enable optimizations | false |
--sourceMaps | Generate source maps | true |
--minify | Minify output (JS only) | false |
--watch | Watch for changes | false |
Examples:
# Build to JavaScript
msc build
# Build to C with optimizations
msc build --target=c --release
# Build specific file
msc build src/main.ms -o build/
# Watch mode
msc build --watchmsc run
Build and execute the program.
msc run [entry] [options] -- [args]Options:
| Option | Description | Default |
|---|---|---|
-t, --target | Compilation target | js |
--release | Enable optimizations | false |
Examples:
# Run with JavaScript
msc run src/main.ms
# Run with C backend
msc run --target=c src/main.ms
# Pass arguments
msc run src/main.ms -- --port 3000msc check
Type-check without compiling.
msc check [files] [options]Options:
| Option | Description | Default |
|---|---|---|
--strict | Enable strict mode | true |
--no-warnings | Hide warnings | false |
Examples:
# Check all files
msc check
# Check specific file
msc check src/main.ms
# Check with all warnings
msc check --strictmsc test
Run tests.
msc test [pattern] [options]Options:
| Option | Description | Default |
|---|---|---|
-t, --target | Compilation target | js |
--watch | Watch for changes | false |
--coverage | Generate coverage report | false |
--filter | Filter tests by name | - |
--parallel | Run tests in parallel | true |
Examples:
# Run all tests
msc test
# Run tests matching pattern
msc test "user*"
# Run with coverage
msc test --coverage
# Filter by name
msc test --filter "should handle errors"msc expand
Show macro expansion output.
msc expand <file> [options]Options:
| Option | Description | Default |
|---|---|---|
--macro | Expand specific macro only | - |
--line | Expand macros at specific line | - |
Examples:
# Expand all macros in file
msc expand src/models.ms
# Expand specific macro
msc expand src/models.ms --macro derive
# Expand at line
msc expand src/models.ms --line 42msc fmt
Format source code.
msc fmt [files] [options]Options:
| Option | Description | Default |
|---|---|---|
--check | Check formatting only | false |
--write | Write changes to files | true |
--config | Path to config file | - |
Examples:
# Format all files
msc fmt
# Check formatting (CI)
msc fmt --check
# Format specific files
msc fmt src/main.ms src/utils.msmsc lint
Run linter.
msc lint [files] [options]Options:
| Option | Description | Default |
|---|---|---|
--fix | Auto-fix issues | false |
--config | Path to config file | - |
Examples:
# Lint all files
msc lint
# Lint and fix
msc lint --fix
# Lint specific directory
msc lint src/msc init
Initialize a new project.
msc init [directory] [options]Options:
| Option | Description | Default |
|---|---|---|
--template | Project template | default |
--name | Project name | directory name |
Templates:
default- Basic projectcli- CLI toollambda- AWS Lambdaotp- Erlang/OTP servicelib- Library package
Examples:
# Initialize in current directory
msc init
# Initialize with template
msc init my-cli --template cli
# Initialize library
msc init my-lib --template libmsc add
Add dependencies.
msc add <packages...> [options]Options:
| Option | Description | Default |
|---|---|---|
-D, --dev | Add as dev dependency | false |
Examples:
# Add runtime dependency
msc add @metascript/http
# Add dev dependency
msc add -D @metascript/testmsc docs
Generate documentation.
msc docs [options]Options:
| Option | Description | Default |
|---|---|---|
-o, --outDir | Output directory | docs/ |
--serve | Serve docs locally | false |
Examples:
# Generate docs
msc docs
# Generate and serve
msc docs --servemsc repl
Start interactive REPL.
msc repl [options]Options:
| Option | Description | Default |
|---|---|---|
-t, --target | Compilation target | js |
--load | Load file before starting | - |
Examples:
# Start REPL
msc repl
# Start with C backend
msc repl --target=c
# Load file first
msc repl --load src/utils.msEnvironment Variables
| Variable | Description |
|---|---|
MSC_TARGET | Default compilation target |
MSC_OUT_DIR | Default output directory |
MSC_CONFIG | Path to config file |
MSC_CACHE_DIR | Compiler cache directory |
MSC_NO_COLOR | Disable colored output |
Exit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | General error |
2 | Type errors |
3 | Configuration error |
4 | Build error |
Next Steps
- Configuration - Project settings
- Language Reference - Syntax guide
- Standard Library - Built-in modules