Skip to content

CLI Reference

Complete reference for all maplibre-yaml CLI commands, options, and arguments.

Available for all commands:

OptionAliasDescription
--help-hShow help for command
--version-vShow CLI version

Validate YAML configuration files against the maplibre-yaml schema.

Terminal window
maplibre-yaml validate <patterns> [options]
ArgumentRequiredDescription
patternsYesFile path(s) or glob pattern(s) to validate

Patterns can be:

  • Single file: map.yaml
  • Glob pattern: configs/**/*.yaml
  • Multiple patterns (space-separated): src/**/*.map.yaml configs/*.yaml
OptionAliasTypeDefaultDescription
--format-fstringhumanOutput format: human, json, sarif, vscode
--strictbooleanfalseTreat warnings as errors
--watch-wbooleanfalseWatch for changes and re-validate

human (default)

  • Human-readable colored output
  • Shows file paths with checkmarks/X marks
  • Displays errors with paths and messages
  • Includes summary with counts

json

  • Structured JSON output
  • Machine-parseable
  • Ideal for CI/CD pipelines
  • Includes detailed error information with line/column numbers

sarif

  • SARIF v2.1.0 format
  • Compatible with GitHub Code Scanning
  • Integrates with GitHub Advanced Security
  • Provides rich error context

vscode

  • VSCode Problem Matcher compatible format
  • Format: file:line:column: severity: [path] message
  • Use with VSCode Tasks for IDE integration
  • See VSCode Integration
CodeMeaning
0All files valid
1Validation errors found
2File(s) not found
3Invalid YAML syntax
4Unknown error

Validate a single file:

Terminal window
maplibre-yaml validate map.yaml

Validate with glob pattern:

Terminal window
maplibre-yaml validate "configs/**/*.yaml"

Validate multiple patterns:

Terminal window
maplibre-yaml validate "src/**/*.map.yaml" "configs/*.yaml"

JSON output for CI/CD:

Terminal window
maplibre-yaml validate "**/*.yaml" --format json

SARIF for GitHub Code Scanning:

Terminal window
maplibre-yaml validate "**/*.yaml" --format sarif > results.sarif

Strict mode (warnings as errors):

Terminal window
maplibre-yaml validate map.yaml --strict

Watch mode for development:

Terminal window
maplibre-yaml validate "configs/**/*.yaml" --watch

VSCode Problem Matcher format:

Terminal window
maplibre-yaml validate config.yaml --format vscode

Start a local development server to preview your map with hot reload.

Terminal window
maplibre-yaml preview <config> [options]
ArgumentRequiredDescription
configYesPath to YAML configuration file
OptionTypeDefaultDescription
--portnumber3000Port for development server
--openbooleantrueOpen browser automatically
--no-openbooleanDon’t open browser (keep server running)
--debugbooleanfalseShow debug panel with config JSON
  • Hot Reload: Automatically updates map when YAML file changes
  • Error Overlay: Shows validation errors with details
  • Status Bar: Displays connection state and file path
  • Live Validation: Validates configuration on every change
  • Debug Panel: Optional JSON view of parsed configuration

Basic preview:

Terminal window
maplibre-yaml preview map.yaml

Custom port:

Terminal window
maplibre-yaml preview map.yaml --port 8080

Don’t open browser:

Terminal window
maplibre-yaml preview map.yaml --no-open

Debug mode:

Terminal window
maplibre-yaml preview map.yaml --debug

Initialize a new maplibre-yaml project with example configurations.

Terminal window
maplibre-yaml init [options]
OptionTypeDefaultDescription
--dirstring.Directory to initialize project in
--templatestringbasicTemplate to use: basic, advanced
  • Sample YAML configuration files
  • .maplibre-yaml.config.json project configuration
  • Example layer configurations
  • README with getting started instructions

Initialize in current directory:

Terminal window
maplibre-yaml init

Initialize in specific directory:

Terminal window
maplibre-yaml init --dir my-maps

Use advanced template:

Terminal window
maplibre-yaml init --template advanced

Create .maplibre-yaml.config.json in your project root to set default options:

{
"validate": {
"format": "human",
"strict": false,
"ignorePatterns": ["**/node_modules/**", "**/dist/**", "**/*.backup.yaml"]
},
"preview": {
"port": 3000,
"open": true
}
}
OptionTypeDefaultDescription
formatstringhumanDefault output format
strictbooleanfalseTreat warnings as errors
ignorePatternsstring[][]Glob patterns to ignore
OptionTypeDefaultDescription
portnumber3000Default server port
openbooleantrueOpen browser by default

CLI arguments always take precedence over config file settings.


The CLI provides a shorter alias for convenience:

Terminal window
# These are equivalent
maplibre-yaml validate map.yaml
mlym validate map.yaml

Use mlym as a shorthand for maplibre-yaml in all commands.


The CLI is optimized for speed:

OperationPerformance
Single file validation~1ms
10 files validation~3ms
100 files validation~80ms
Watch mode (cached)~1ms per file
CLI startup (--help)~350ms

The validate command processes files in parallel with a default concurrency of 10. For large file sets (>10 files), a progress indicator shows validation status in real-time.

Watch mode uses mtime-based caching to avoid re-validating unchanged files. Only modified files are re-validated, making watch mode extremely fast for development workflows.


All commands use consistent exit codes:

CodeMeaningCommands
0SuccessAll
1Validation errorsvalidate
2File not foundvalidate, preview
3Invalid YAML syntaxvalidate
4Unknown errorAll

Use exit codes in scripts and CI/CD pipelines to detect failures:

Terminal window
if maplibre-yaml validate "**/*.yaml"; then
echo "All configurations valid"
else
echo "Validation failed with exit code $?"
exit 1
fi

Set to production to disable debug output:

Terminal window
NODE_ENV=production maplibre-yaml validate "**/*.yaml"

Disable colored output:

Terminal window
NO_COLOR=1 maplibre-yaml validate map.yaml

Add to package.json:

{
"scripts": {
"validate": "maplibre-yaml validate 'configs/**/*.yaml'",
"validate:watch": "maplibre-yaml validate 'configs/**/*.yaml' --watch",
"preview": "maplibre-yaml preview map.yaml",
"validate:ci": "maplibre-yaml validate '**/*.yaml' --format json --strict"
}
}
name: Validate Maps
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npx @maplibre-yaml/cli validate "**/*.yaml" --format json --strict
name: Code Scanning
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npx @maplibre-yaml/cli validate "**/*.yaml" --format sarif > results.sarif
- uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif

Using husky:

#!/bin/sh
npx maplibre-yaml validate "$(git diff --cached --name-only --diff-filter=ACM | grep '\.yaml$')"

If maplibre-yaml command is not found:

  1. Install globally: npm install -g @maplibre-yaml/cli
  2. Use npx: npx @maplibre-yaml/cli <command>
  3. Check PATH includes npm global bin directory
  • Quote patterns to prevent shell expansion: "configs/**/*.yaml"
  • Use absolute paths or run from project root
  • Check ignore patterns in config file
  • Ensure file is within watched pattern
  • Check file system limits (increase with ulimit -n 4096)
  • Verify file permissions
  • Ensure read access to all matched files
  • Check directory permissions
  • Run with appropriate user permissions