51dbe8c27714154935d40e6cae0f4f68491c625a
Some checks failed
CI / test (push) Has been cancelled
Config Converter CLI
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
# 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
pip install config-converter-cli
Usage
Basic Conversion
Convert a single file from one format to another:
# 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.
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.
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.
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:
{
"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.
config-converter validate config.json [-f FORMAT]
generate-ts
Generate TypeScript interfaces from a configuration file.
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:
export interface Config {
name: string;
version: string;
port: number;
database: {
host: string;
port: number;
};
}
interactive
Enter interactive mode for guided conversion.
config-converter interactive
formats
List all supported formats.
config-converter formats
Examples
Convert configuration with nested structures
// config.json
{
"app": {
"name": "myapp",
"version": "1.0.0"
},
"database": {
"host": "localhost",
"port": 5432,
"ssl": true
}
}
config-converter convert config.json -t yaml -o config.yaml
# config.yaml
app:
name: myapp
version: 1.0.0
database:
host: localhost
port: 5432
ssl: true
Batch conversion
# Convert all JSON config files to YAML
config-converter batch "configs/*.json" -t yaml -o configs/yaml/
Generate TypeScript interfaces
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
pytest tests/ -v
Installing Dev Dependencies
pip install -e ".[dev]"
License
MIT
Description
A CLI tool for real-time bidirectional conversion and validation between JSON, YAML, and TOML formats with JMESPath query support.