Skip to main content

A command-line tool to convert between various configuration file formats (JSON, YAML, TOML, .env, INI, XML).

Project description

Universal Config Converter

License: MIT

Tired of manually converting configuration files between JSON, YAML, TOML, .env, and others? This simple command-line tool aims to make your life easier by automating the conversion process.

config-converter allows you to effortlessly switch between common configuration formats, saving you time and reducing potential errors.

Goals

  • Provide a single, reliable CLI tool for converting between the most popular configuration formats.
  • Ensure the conversion process is accurate and preserves data structure.
  • Maintain a simple and intuitive user interface.
  • Build a community-driven tool that adapts to new formats and user needs.

Features & Roadmap

Here's what the tool can do and what's planned for the future:

  • Command-Line Interface (CLI): Easy-to-use commands via click.
  • Core Conversion Logic: Foundation for loading and saving data.
  • JSON Support: Convert to/from JSON (.json).
  • YAML Support: Convert to/from YAML (.yaml, .yml).
  • TOML Support: Convert to/from TOML (.toml).
  • .env Support: Convert to/from environment variable files (.env).
  • INI Support: Convert to/from INI files (.ini).
  • XML Support: Convert to/from XML files (.xml).
  • Comment Preservation: Attempt to keep comments intact during conversion.
    • YAML (using ruamel.yaml, load/save cycle preserves comments)
    • INI (Potential future enhancement)
    • TOML (Potential future enhancement with tomlkit)
    • Note: Comments are generally lost for JSON, .env, XML conversions.
  • Data Validation: Option to validate input/output against a JSON schema.
  • Basic Unit Tests: Initial tests for core functionality.
  • Comprehensive Test Suite: More tests covering edge cases and all formats (Further additions welcome!).
  • Pre-commit Hooks: Ensure code quality and consistency.
  • PyPI Packaging: Make it easily installable via pip install config-converter.
  • GitHub Actions CI: Automate testing on pushes and pull requests.

Installation

  1. Clone the repository:
    git clone https://github.com/velibenek/universal-config-converter.git
    cd universal-config-converter
    
  2. Create and activate a virtual environment (Recommended):
    python3 -m venv .venv
    source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
    
  3. Install dependencies:
    pip install -r requirements.txt
    # Also install pytest for running tests
    pip install pytest
    

Usage

Convert a file from one format to another:

config-converter -i <input_path> -s <format> -t <format> -o <output_path> [options]

Example: Convert config.json to config.yaml:

config-converter -i config.json -s json -t yaml -o config.yaml

Example with Input Validation: Validate config.json against schema.json before converting:

config-converter -i config.json -s json -t yaml -o config.yaml --input-schema schema.json

Example with Output Validation: Convert config.json to config.yaml and validate the result against schema.json before saving:

config-converter -i config.json -s json -t yaml -o config.yaml --output-schema schema.json

Supported formats currently: json, yaml, toml, env, ini, xml.

Contributing

Contributions are welcome! If you'd like to help improve config-converter, please feel free to:

  • Report bugs or suggest features by opening an issue.
  • Submit pull requests with bug fixes or new features (especially those on the roadmap!).
  • Improve the documentation.

Please check the CONTRIBUTING.md file (to be created) for more detailed guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Homepage Issues

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

universal_config_converter-0.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

universal_config_converter-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file universal_config_converter-0.1.0.tar.gz.

File metadata

File hashes

Hashes for universal_config_converter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a8669533bf3a37954c74659faeaac9981a3d6be0b8e05f9c23c744df1a2b24bc
MD5 aa34fa96b278aa80aee3e9429a1fe15e
BLAKE2b-256 428524987341352753c74ae6a68eee777b8fa8f63ad7c51230f1dca472592849

See more details on using hashes here.

File details

Details for the file universal_config_converter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for universal_config_converter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73585b72b560509c5be9a57d4c594608c4c75437562670400d5bc1222d293663
MD5 fb92f2823ea879984975f721fd71a9f5
BLAKE2b-256 878946266b1372f5eadf8a8af2f6956bd1572d620e97a1617d29e65cb7b8f20f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page