// DOCS NAVIGATION
CLI_REFERENCE
SOURCE: section 5 of 01-introducao.md + README essentials
SOURCE: section 5 of content/docs/reference/01-introducao.md
[ FROM THE REFERENCE ]
5. Interface de Linha de Comando / Command-Line Interface
PT-BR:
O CLI do SpectraLang (spectralang) oferece os seguintes comandos e opções:
EN-US:
The SpectraLang CLI (spectralang) provides the following commands and options:
Comandos / Commands
| Comando / Command | Descrição PT-BR | Description EN-US |
|---|---|---|
spectralang run <arquivo> | Compila e executa via JIT | Compile and execute via JIT |
spectralang compile <arquivo> | Compila via JIT sem executar | Compile via JIT without executing |
spectralang check <arquivo> | Verifica tipos sem compilar | Type-check only, no code generation |
spectralang lint <arquivo> | Executa verificações de lint | Run lint checks |
spectralang fmt <arquivo> | Formata o código-fonte | Format source code |
spectralang repl | Inicia o REPL interativo | Start the interactive REPL |
spectralang new <nome> | Cria um novo projeto | Scaffold a new project |
Flags
| Flag | Descrição PT-BR | Description EN-US |
|---|---|---|
--run / -r | Executa após compilar (JIT) | Execute after compilation (JIT) |
--emit-object <saída> | Gera arquivo objeto AOT | Generate AOT object file |
--no-optimize / -O0 | Desativa todas as otimizações | Disable all optimizations |
-O1 | Constant folding ativado | Constant folding enabled |
-O2 | Constant folding + eliminação de código morto (padrão) | Constant folding + dead code elimination (default) |
-O3 | Todas as otimizações agressivas | All aggressive optimizations |
--dump-ast | Exibe a árvore AST para debug | Print the AST for debugging |
--dump-ir | Exibe o IR para debug | Print the IR for debugging |
--timings / -T | Coleta métricas de compilação | Collect compilation metrics |
--summary | Exibe sumário do pipeline por módulo | Show per-module pipeline summaries |
--verbose / -v | Detalhes adicionais do build | Print additional build details |
--lint | Ativa verificações de lint | Enable lint checks |
--allow <rule> | Permite (suprime) uma regra de lint | Allow (suppress) a lint rule |
--deny <rule> | Eleva uma regra de lint a erro | Escalate a lint rule to error |
--enable-experimental <feature> | Compatibilidade com scripts antigos; sem gates ativos | Compatibility no-op; no active experimental syntax gates |
Exemplos de Uso / Usage Examples
# Executar um programa / Run a program
spectralang run hello.spectra
# Verificar tipos apenas / Type-check only
spectralang check meu_programa.spectra
# Compilar com otimização nível 2 / Compile with level-2 optimization
spectralang compile -O2 algoritmos.spectra
# Gerar arquivo objeto AOT / Generate AOT object file
spectralang compile --emit-object meu_programa.o programa.spectra
# Formatar o código / Format the code
spectralang fmt meu_arquivo.spectra
# Lint com saída JSON / Lint with JSON output
spectralang lint --json meu_arquivo.spectra
# Iniciar REPL / Start REPL
spectralang repl
Códigos de Saída / Exit Codes
| Código / Code | Significado PT-BR | Meaning EN-US |
|---|---|---|
0 | Sucesso | Success |
64 | Erro de uso (argumentos inválidos) | Usage error (invalid arguments) |
65 | Erro de compilação | Compilation error |
74 | Erro de I/O | I/O error |
SNAPSHOT: README.md — CLI Essentials table (maintained on the home page)
[ CLI ESSENTIALS — SNAPSHOT ]
| COMMAND | DESCRIPTION |
|---|---|
spectralang compile <paths> | Compile Spectra modules (default). |
spectralang check <paths> | Type-check modules and report diagnostics without executing. |
spectralang run <paths> | Compile modules and execute the entry point via JIT. |
spectralang lint <paths> | Run lint checks and report warnings or denied rules. |
spectralang bench <paths> | Compile with timing metrics and optional JSON report. |
spectralang fmt <paths> | Format Spectra source files. |
spectralang repl | Start an interactive Spectra prompt. |
spectralang new <path> | Scaffold a new Spectra project. |
spectralang package <action> | Resolve, lock, build, publish, and consume packages. |
spectralang release-info | Report CLI and package release channel metadata. |