@morphql/cli
v0.1.19
Published
CLI tool for morphql - transform structural data from the command line.
Maintainers
Readme
@morphql/cli
The command-line interface for MorphQL. Transform structural data (JSON, XML, CSV, etc.) directly from your terminal using declarative queries.
Key Features
- 🏎️ Fast Execution: Compiles queries to optimized native JavaScript functions.
- 📂 Batch Processing: Transform entire directories of files in one command.
- 👁️ Watch Mode: Real-time directory monitoring and automatic transformation.
- 📊 Structured Logging: Human-readable
textor machine-parsablejsonoutput. - 🧩 Lightweight: Minimal dependencies, leveraging Node.js native modules where possible.
Installation
npm install -g @morphql/cliBasic Usage
Single File (Default)
# Inline transformation
echo '{"name":"Alice"}' | morphql -q "from json to xml"
# File-to-file
morphql --from data.json --to output.xml -q "from json to xml"Batch Processing
morphql batch \
-q "from xml to json transform set status = 'processed'" \
--in ./inbox \
--out ./outbox \
--pattern "*.xml"Watch Mode
morphql watch \
-q "from csv to json" \
--in ./incoming \
--out ./processed \
--deleteOptions Summary
| Feature | Example | Description |
| :----------- | :--------------------- | :----------------------------------------------- |
| Patterm | --pattern "*.json" | Filter which files to process. |
| Archive | --done-dir ./done | Move files here after success. |
| Error | --error-dir ./err | Move files here on failure. |
| Cleanup | --delete | Remove source files after successful processing. |
| Logging | --log-format json | Output JSONL for automated monitoring. |
| PID File | --pid-file morph.pid | Write process PID for service management. |
Learn More
License
MIT
