# Config Converter CLI [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/) [![Gitea Actions](https://7000pct.gitea.bloupla.net/7000pctAUTO/config-converter-cli/actions/workflows/ci.yml/badge.svg)](https://7000pct.gitea.bloupla.net/7000pctAUTO/config-converter-cli/actions) A powerful CLI tool for converting configuration files between JSON, YAML, TOML, and INI formats with schema inference, validation, TypeScript interface generation, and colorized output. ## Features - **Multi-format Conversion**: Convert between JSON, YAML, TOML, and INI formats - **Schema Inference**: Automatically infer schemas from configuration files - **Validation**: Validate configuration files against inferred schemas - **TypeScript Generation**: Generate TypeScript interfaces from configurations - **Batch Processing**: Convert multiple files using glob patterns - **Colorized Output**: Beautiful colored output using Rich library - **Interactive Mode**: Guided conversion workflow ## Installation ### From Source ```bash # Clone the repository git clone https://7000pct.gitea.bloupla.net/7000pctAUTO/config-converter-cli.git cd config-converter-cli # Install dependencies pip install -e . # Or install with dev dependencies pip install -e ".[dev]" ``` ### From PyPI ```bash pip install config-converter-cli ``` ## Usage ### Basic Conversion Convert a single file from one format to another: ```bash # Convert JSON to YAML config-converter convert config.json -t yaml -o config.yaml # Convert YAML to TOML config-converter convert settings.yaml -t toml -o settings.toml # Auto-detect format from extension config-converter convert app.json --to yaml -o app.yaml ``` ### Supported Formats - **JSON** (`.json`) - **YAML** (`.yaml`, `.yml`) - **TOML** (`.toml`) - **INI** (`.ini`, `.cfg`) ## Commands ### convert Convert a configuration file from one format to another. ```bash config-converter convert SOURCE -t FORMAT [-o OUTPUT] [-f FORMAT] [-w] Options: -t, --to FORMAT Target format (required) -o, --output FILE Output file path -f, --from FORMAT Source format (auto-detected if not specified) -w, --overwrite Overwrite output file if it exists ``` ### batch Convert multiple files matching a glob pattern. ```bash config-converter batch "*.json" -t yaml -o ./output/ Options: -t, --to FORMAT Target format (required) -o, --output-dir DIR Output directory -f, --from FORMAT Source format (auto-detected if not specified) -w, --overwrite Overwrite output files if they exist ``` ### infer Infer and display the schema of a configuration file. ```bash config-converter infer config.json [-f FORMAT] [-t] [-t] Options: -f, --format FORMAT Input format (auto-detected if not specified) -t, --table Display as table --tree Display as tree structure ``` Example output: ```json { "root_type": "object", "properties": [ {"name": "name", "type": "string", "required": true}, {"name": "version", "type": "string", "required": true}, {"name": "port", "type": "integer", "required": true} ] } ``` ### validate Validate a configuration file against its inferred schema. ```bash config-converter validate config.json [-f FORMAT] ``` ### generate-ts Generate TypeScript interfaces from a configuration file. ```bash config-converter generate-ts config.json [-f FORMAT] [-i NAME] [-o FILE] Options: -i, --interface NAME Interface name (default: "Config") -o, --output FILE Output file path ``` Example output: ```typescript export interface Config { name: string; version: string; port: number; database: { host: string; port: number; }; } ``` ### interactive Enter interactive mode for guided conversion. ```bash config-converter interactive ``` ### formats List all supported formats. ```bash config-converter formats ``` ## Examples ### Convert configuration with nested structures ```json // config.json { "app": { "name": "myapp", "version": "1.0.0" }, "database": { "host": "localhost", "port": 5432, "ssl": true } } ``` ```bash config-converter convert config.json -t yaml -o config.yaml ``` ```yaml # config.yaml app: name: myapp version: 1.0.0 database: host: localhost port: 5432 ssl: true ``` ### Batch conversion ```bash # Convert all JSON config files to YAML config-converter batch "configs/*.json" -t yaml -o configs/yaml/ ``` ### Generate TypeScript interfaces ```bash config-converter generate-ts app.config.json -i AppConfig -o app.config.ts ``` ## Configuration ### Environment Variables - `NO_COLOR`: Set to disable colorized output ## Development ### Running Tests ```bash pytest tests/ -v ``` ### Installing Dev Dependencies ```bash pip install -e ".[dev]" ``` ## License MIT