Command Line Interface
The MD-Models command-line interface (CLI) provides a comprehensive set of tools for working with markdown data models. It enables you to validate models, generate code in multiple formats, extract data using AI, and automate workflows through pipelines.
Installation
Install the MD-Models CLI using Cargo:
cargo install mdmodels
Once installed, you can use the md-models command from anywhere in your terminal.
Available Commands
The MD-Models CLI provides the following commands:
validate
Validates markdown model files for structural integrity, naming conventions, and type consistency.
Quick start:
md-models validate -i model.md
Use cases:
- Check models before code generation
- Validate models in CI/CD pipelines
- Ensure models meet naming and structure requirements
Learn more: Schema Validation
convert
Converts markdown models to various output formats including programming languages, schema definitions, API specifications, and documentation.
Quick start:
# Generate Python Pydantic models
md-models convert -i model.md -t python-pydantic -o models.py
# Generate JSON Schema
md-models convert -i model.md -t json-schema -r Document -o schema.json
Use cases:
- Generate type-safe code for your application
- Create API schemas and specifications
- Produce documentation from models
- Export to semantic web formats
Learn more: Code Generation
Available formats: See Exporters for a complete list of supported templates.
pipeline
Generates multiple output files from one or more models using a TOML configuration file. Ideal for automating code generation workflows.
Quick start:
md-models pipeline -i pipeline.toml
Use cases:
- Generate multiple formats in one command
- Automate code generation for entire projects
- Maintain consistency across generated outputs
- Integrate with CI/CD workflows
Learn more: Pipelines
extract
Uses Large Language Models (LLMs) to extract structured data from unstructured text based on your data model.
Quick start:
md-models extract -m model.md -i text.txt -o output.json
Use cases:
- Extract structured data from documents
- Parse unstructured text into typed objects
- Convert legacy data formats to structured JSON
- Automate data entry tasks
Learn more: Large Language Models
dataset validate
Validates JSON datasets against markdown models to ensure data conforms to the model structure.
Quick start:
md-models dataset validate -i data.json -m model.md
Use cases:
- Validate API request/response data
- Check data quality in ETL pipelines
- Ensure data consistency before processing
- Validate user-submitted data
Common Workflows
Development Workflow
# 1. Validate your model
md-models validate -i model.md
# 2. Generate code for your application
md-models convert -i model.md -t python-pydantic -o models.py
# 3. Generate API schemas
md-models convert -i model.md -t json-schema -r Document -o schema.json
md-models convert -i model.md -t graphql -o schema.graphql
Automated Pipeline Workflow
# Use a pipeline configuration to generate everything at once
md-models pipeline -i pipeline.toml
Data Extraction Workflow
# Extract structured data from unstructured text
md-models extract -m model.md -i document.txt -o extracted.json
# Validate the extracted data
md-models dataset validate -i extracted.json -m model.md
Input Sources
All commands that accept input files support:
- Local file paths:
md-models validate -i model.md - Remote URLs:
md-models validate -i https://example.com/model.md
MD-Models automatically detects whether the input is a URL (starts with http/https) or a local file path.
Getting Help
Get help for any command using the --help flag:
# General help
md-models --help
# Command-specific help
md-models convert --help
md-models validate --help
md-models pipeline --help
Command Reference
| Command | Purpose | Documentation |
|---|---|---|
validate | Validate model structure and syntax | Schema Validation |
convert | Generate code and schemas | Code Generation |
pipeline | Batch generation from config | Pipelines |
extract | LLM-powered data extraction | Large Language Models |
dataset validate | Validate data against models | See md-models dataset validate --help |
Next Steps
- New to MD-Models? Start with the Quickstart guide
- Want to generate code? Read Code Generation for detailed usage
- Need to validate models? See Schema Validation for validation rules
- Automating workflows? Check out Pipelines for batch processing
- Working with AI? Explore Large Language Models for data extraction
For detailed information about available export formats and templates, see the Exporters documentation.