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 (Difficult with standard configparser, potential future enhancement)
    • TOML (using tomlkit, load/save cycle preserves comments)
    • 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.2.0.tar.gz (14.0 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.2.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for universal_config_converter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4bdbe5403b8dfa1df1aed728ec7f716aba23b62d8a83b9a29f8e74ba9fe6390a
MD5 50783131314f7120f4836469dfbf0e72
BLAKE2b-256 7805db1bb2ea5b2a793ce1e0d086a87eeb071560ee1183f51a9f56a0507b54d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for universal_config_converter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 607eec86030e5ed7a82419509e4db83033104aaaedc80ec652535d37481a95de
MD5 844c82420a1e2e9eaa748d161021e0c8
BLAKE2b-256 ea8aac4c20cb8137e17c97ef5a1f84f79fe0f8c13972a8c0439bbbf1c971c50f

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