|
1 | 1 | # Command Line Interface |
2 | 2 |
|
3 | | -*To be added* |
| 3 | +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. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +Install the MD-Models CLI using Cargo: |
| 8 | + |
| 9 | +```bash |
| 10 | +cargo install mdmodels |
| 11 | +``` |
| 12 | + |
| 13 | +Once installed, you can use the `md-models` command from anywhere in your terminal. |
| 14 | + |
| 15 | +## Available Commands |
| 16 | + |
| 17 | +The MD-Models CLI provides the following commands: |
| 18 | + |
| 19 | +### `validate` |
| 20 | + |
| 21 | +Validates markdown model files for structural integrity, naming conventions, and type consistency. |
| 22 | + |
| 23 | +**Quick start:** |
| 24 | + |
| 25 | +```bash |
| 26 | +md-models validate -i model.md |
| 27 | +``` |
| 28 | + |
| 29 | +**Use cases:** |
| 30 | +- Check models before code generation |
| 31 | +- Validate models in CI/CD pipelines |
| 32 | +- Ensure models meet naming and structure requirements |
| 33 | + |
| 34 | +**Learn more:** [Schema Validation](schema_validation.md) |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +### `convert` |
| 39 | + |
| 40 | +Converts markdown models to various output formats including programming languages, schema definitions, API specifications, and documentation. |
| 41 | + |
| 42 | +**Quick start:** |
| 43 | + |
| 44 | +```bash |
| 45 | +# Generate Python Pydantic models |
| 46 | +md-models convert -i model.md -t python-pydantic -o models.py |
| 47 | + |
| 48 | +# Generate JSON Schema |
| 49 | +md-models convert -i model.md -t json-schema -r Document -o schema.json |
| 50 | +``` |
| 51 | + |
| 52 | +**Use cases:** |
| 53 | +- Generate type-safe code for your application |
| 54 | +- Create API schemas and specifications |
| 55 | +- Produce documentation from models |
| 56 | +- Export to semantic web formats |
| 57 | + |
| 58 | +**Learn more:** [Code Generation](generation.md) |
| 59 | + |
| 60 | +**Available formats:** See [Exporters](../exporters/exporters.md) for a complete list of supported templates. |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +### `pipeline` |
| 65 | + |
| 66 | +Generates multiple output files from one or more models using a TOML configuration file. Ideal for automating code generation workflows. |
| 67 | + |
| 68 | +**Quick start:** |
| 69 | + |
| 70 | +```bash |
| 71 | +md-models pipeline -i pipeline.toml |
| 72 | +``` |
| 73 | + |
| 74 | +**Use cases:** |
| 75 | +- Generate multiple formats in one command |
| 76 | +- Automate code generation for entire projects |
| 77 | +- Maintain consistency across generated outputs |
| 78 | +- Integrate with CI/CD workflows |
| 79 | + |
| 80 | +**Learn more:** [Pipelines](pipelines.md) |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +### `extract` |
| 85 | + |
| 86 | +Uses Large Language Models (LLMs) to extract structured data from unstructured text based on your data model. |
| 87 | + |
| 88 | +**Quick start:** |
| 89 | + |
| 90 | +```bash |
| 91 | +md-models extract -m model.md -i text.txt -o output.json |
| 92 | +``` |
| 93 | + |
| 94 | +**Use cases:** |
| 95 | +- Extract structured data from documents |
| 96 | +- Parse unstructured text into typed objects |
| 97 | +- Convert legacy data formats to structured JSON |
| 98 | +- Automate data entry tasks |
| 99 | + |
| 100 | +**Learn more:** [Large Language Models](llm.md) |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +### `dataset validate` |
| 105 | + |
| 106 | +Validates JSON datasets against markdown models to ensure data conforms to the model structure. |
| 107 | + |
| 108 | +**Quick start:** |
| 109 | + |
| 110 | +```bash |
| 111 | +md-models dataset validate -i data.json -m model.md |
| 112 | +``` |
| 113 | + |
| 114 | +**Use cases:** |
| 115 | +- Validate API request/response data |
| 116 | +- Check data quality in ETL pipelines |
| 117 | +- Ensure data consistency before processing |
| 118 | +- Validate user-submitted data |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## Common Workflows |
| 123 | + |
| 124 | +### Development Workflow |
| 125 | + |
| 126 | +```bash |
| 127 | +# 1. Validate your model |
| 128 | +md-models validate -i model.md |
| 129 | + |
| 130 | +# 2. Generate code for your application |
| 131 | +md-models convert -i model.md -t python-pydantic -o models.py |
| 132 | + |
| 133 | +# 3. Generate API schemas |
| 134 | +md-models convert -i model.md -t json-schema -r Document -o schema.json |
| 135 | +md-models convert -i model.md -t graphql -o schema.graphql |
| 136 | +``` |
| 137 | + |
| 138 | +### Automated Pipeline Workflow |
| 139 | + |
| 140 | +```bash |
| 141 | +# Use a pipeline configuration to generate everything at once |
| 142 | +md-models pipeline -i pipeline.toml |
| 143 | +``` |
| 144 | + |
| 145 | +### Data Extraction Workflow |
| 146 | + |
| 147 | +```bash |
| 148 | +# Extract structured data from unstructured text |
| 149 | +md-models extract -m model.md -i document.txt -o extracted.json |
| 150 | + |
| 151 | +# Validate the extracted data |
| 152 | +md-models dataset validate -i extracted.json -m model.md |
| 153 | +``` |
| 154 | + |
| 155 | +## Input Sources |
| 156 | + |
| 157 | +All commands that accept input files support: |
| 158 | + |
| 159 | +- **Local file paths**: `md-models validate -i model.md` |
| 160 | +- **Remote URLs**: `md-models validate -i https://example.com/model.md` |
| 161 | + |
| 162 | +MD-Models automatically detects whether the input is a URL (starts with `http`/`https`) or a local file path. |
| 163 | + |
| 164 | +## Getting Help |
| 165 | + |
| 166 | +Get help for any command using the `--help` flag: |
| 167 | + |
| 168 | +```bash |
| 169 | +# General help |
| 170 | +md-models --help |
| 171 | + |
| 172 | +# Command-specific help |
| 173 | +md-models convert --help |
| 174 | +md-models validate --help |
| 175 | +md-models pipeline --help |
| 176 | +``` |
| 177 | + |
| 178 | +## Command Reference |
| 179 | + |
| 180 | +| Command | Purpose | Documentation | |
| 181 | +|---------|---------|---------------| |
| 182 | +| `validate` | Validate model structure and syntax | [Schema Validation](schema_validation.md) | |
| 183 | +| `convert` | Generate code and schemas | [Code Generation](generation.md) | |
| 184 | +| `pipeline` | Batch generation from config | [Pipelines](pipelines.md) | |
| 185 | +| `extract` | LLM-powered data extraction | [Large Language Models](llm.md) | |
| 186 | +| `dataset validate` | Validate data against models | See `md-models dataset validate --help` | |
| 187 | + |
| 188 | +## Next Steps |
| 189 | + |
| 190 | +- **New to MD-Models?** Start with the [Quickstart](../quickstart.md) guide |
| 191 | +- **Want to generate code?** Read [Code Generation](generation.md) for detailed usage |
| 192 | +- **Need to validate models?** See [Schema Validation](schema_validation.md) for validation rules |
| 193 | +- **Automating workflows?** Check out [Pipelines](pipelines.md) for batch processing |
| 194 | +- **Working with AI?** Explore [Large Language Models](llm.md) for data extraction |
| 195 | + |
| 196 | +For detailed information about available export formats and templates, see the [Exporters](../exporters/exporters.md) documentation. |
0 commit comments