#CLI
The masterbelt command is the user-facing command line entry point.
Commands must read project configuration before running behavior that depends on user project settings.
Global options:
-c PATHand--config PATHexplicitly select the project configuration file.--reporter FORMATselects the diagnostic reporter.- Supported formats are
textandjson. textis the default and writes diagnostics to standard error.jsonwrites diagnostics to standard output by default.- JSON diagnostics can mix with command output when a command also writes primary output to standard output.
- For machine-readable diagnostic output, use
jsonwith commands or modes that do not also emit primary output to standard output, such asfmt --checkandfmt --write.
- Supported formats are
- Reporter shorthand:
--textis shorthand for--reporter text.--jsonis shorthand for--reporter json.--textand--jsonare mutually exclusive.- Reporter shorthand options conflict with an explicit
--reportervalue that selects a different format.
#Diagnostic Output
- Text diagnostics are written to standard error.
- JSON diagnostics are written to standard output.
#fmt
masterbelt fmt formats Masterbelt source files.
#Input
- Formatter inputs must be valid Masterbelt source text, including the language UTF-8 source text requirement.
- Invalid UTF-8 input fails formatting.
- Empty input is considered already formatted.
- When file paths are provided, the command formats each file independently.
- When no file path is provided, the command reads one source file from standard input and writes formatted source to standard output.
#Modes
- Without
--checkor--write, at most one file path may be provided. - Formatting multiple files to standard output is invalid because the output would not preserve file boundaries.
--checkreports whether each input is already formatted.--checkapplies to file inputs and to standard input.--checkmust not write formatted source to files or standard output.--checkfails when any input would change.--writeupdates file inputs in place.--writecannot be used when reading from standard input.--checkand--writeare mutually exclusive.- The default mode writes formatted source to standard output.
--checkand--writesuppress formatted source output.
#Configuration
- The formatter indentation option is resolved from project configuration for each file input.
- Standard input uses configuration discovered from the current working directory.
#codegen
masterbelt codegen runs every code generation target configured in the project's masterbelt.yml.
#Input
- The command reads the project configuration to discover the entrypoint and the configured target list.
- An entrypoint is required (see
tooling/configuration); the command fails whenentry:is missing. - The command analyzes and lowers the entrypoint into the IR program model that targets consume. Future multi-file support follows once imports are implemented.
#Modes
- The command runs every configured target by default.
- The command does not read from standard input and does not write to standard output. Generated source is written to disk under each target's configured
outdirectory. - Each invocation overwrites any existing file at the same output path; the command does not perform incremental updates and does not delete files left over from previous runs.
#Output
- Output files are written into each target's
outdirectory, creating parent directories as needed. - The text reporter is silent on success.
- The JSON reporter writes an empty diagnostic envelope on success.
#Configuration
- A project configured with no targets is a no-op: the command exits with code 0 and writes no files.
- A target whose
kinddoes not match any registered code generation target produces a diagnostic and the command fails.
#export
masterbelt export imports the project's master data, validates it, and writes the configured export artifacts.
#Validation
- Export imports each master's source records and applies each master's filter, then runs each master's validation rules over the post-filter records before writing any artifact.
- An
error-severity validation failure (a failedassertwhose resolved severity iserror) blocks the entire export: no file is written. Awarning-severity failure is reported but does not block the export. - A validator-configuration error (
masterbelt.validation.config_unknown_master,masterbelt.validation.config_unknown_validator, ormasterbelt.validation.config_invalid_severity) is detected before validators run and likewise blocks the entire export. - An import error blocks the export as well; export proceeds to validation and writing only when import succeeds.
#SQLite Index Inference
When the SQLite exporter is configured, a master's indexed scope declarations drive secondary-index generation, defined in export-sqlite.md. Generating an index reports masterbelt.scope.index_generated (info) and a scope that cannot be fully inferred reports masterbelt.scope.index_inference_failed (warning); neither severity blocks the export.
#Exit Codes
- 0: the requested operation succeeds.
- 1: execution fails after command-line arguments are accepted, including diagnostics, unreadable inputs, unwritable outputs, invalid project configuration, or
fmt --checkdetecting inputs that would change. - 2: command-line arguments are invalid.