110 lines
2.2 KiB
Markdown
110 lines
2.2 KiB
Markdown
# ConfigConvert CLI
|
|
|
|
A powerful CLI tool for bidirectional conversion between JSON, YAML, TOML, and ENV config formats.
|
|
|
|
## Features
|
|
|
|
- **Bidirectional Conversion**: Convert between any combination of supported formats
|
|
- **Smart Type Inference**: Automatically detect and convert string values to appropriate Python types
|
|
- **Syntax Validation**: Validate syntax of input files before conversion
|
|
- **Flatten/Unflatten**: Transform nested structures to/from dot-notation keys
|
|
- **Schema Generation**: Generate JSON Schema from parsed configurations
|
|
- **Shell Completion**: Built-in support for bash, zsh, and fish completions
|
|
- **Offline Operation**: Runs entirely offline with minimal dependencies
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
pip install config-convert-cli
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Convert between formats
|
|
|
|
```bash
|
|
# Convert JSON to YAML
|
|
config-convert convert input.json --to yaml -o output.yaml
|
|
|
|
# Convert YAML to JSON
|
|
config-convert convert config.yaml --from yaml --to json
|
|
|
|
# Convert ENV to JSON
|
|
config-convert convert .env --from env --to json
|
|
|
|
# Pretty print output
|
|
config-convert convert config.json --to yaml --pretty
|
|
```
|
|
|
|
### Validate syntax
|
|
|
|
```bash
|
|
config-validate config.yaml
|
|
```
|
|
|
|
### Flatten nested structures
|
|
|
|
```bash
|
|
config-convert flatten config.json --output flat.env
|
|
```
|
|
|
|
### Unflatten to nested structures
|
|
|
|
```bash
|
|
config-convert unflatten flat.env --output nested.yaml
|
|
```
|
|
|
|
### Generate JSON Schema
|
|
|
|
```bash
|
|
config-convert schema config.json -o schema.json
|
|
```
|
|
|
|
## Supported Formats
|
|
|
|
| Format | Extension | Read | Write |
|
|
|--------|-----------|------|-------|
|
|
| JSON | .json | ✓ | ✓ |
|
|
| YAML | .yaml | ✓ | ✓ |
|
|
| TOML | .toml | ✓ | ✓ |
|
|
| ENV | .env | ✓ | ✓ |
|
|
|
|
## Shell Completion
|
|
|
|
### Bash
|
|
|
|
```bash
|
|
# Install completions
|
|
config-convert --install-completion bash
|
|
|
|
# Or source directly
|
|
source <(config-convert --show-completion bash)
|
|
```
|
|
|
|
### Zsh
|
|
|
|
```bash
|
|
config-convert --install-completion zsh
|
|
```
|
|
|
|
### Fish
|
|
|
|
```bash
|
|
config-convert --install-completion fish
|
|
```
|
|
|
|
## Exit Codes
|
|
|
|
| Code | Description |
|
|
|------|-------------|
|
|
| 0 | Success |
|
|
| 1 | General error |
|
|
| 2 | Invalid arguments |
|
|
| 3 | File not found |
|
|
| 4 | Syntax error in input |
|
|
| 5 | Conversion error |
|
|
|
|
## License
|
|
|
|
MIT
|