Add core files: README, Cargo.toml, LICENSE
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-01-29 15:13:09 +00:00
parent e292479a33
commit c060fa2f90

244
README.md
View File

@@ -1,3 +1,245 @@
# config-forge # ConfigForge
[![CI](https://7000pct.gitea.bloupla.net/7000pctAUTO/config-forge/actions/workflows/ci.yml/badge.svg)](https://7000pct.gitea.bloupla.net/7000pctAUTO/config-forge/actions)
[![Version](https://img.shields.io/badge/version-0.1.0-blue)](https://7000pct.gitea.bloupla.net/7000pctAUTO/config-forge/releases)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
A powerful CLI tool for converting between configuration formats (JSON, YAML, TOML, ENV, INI) with built-in validation, schema inference, and TypeScript interface generation. A powerful CLI tool for converting between configuration formats (JSON, YAML, TOML, ENV, INI) with built-in validation, schema inference, and TypeScript interface generation.
## Features
- **Format Conversion**: Convert seamlessly between JSON, YAML, TOML, ENV, and INI formats
- **Schema Validation**: Validate configurations against JSON Schema specifications
- **TypeScript Generation**: Generate TypeScript interfaces from configurations
- **Batch Processing**: Convert multiple files with glob pattern support
- **Syntax Highlighting**: Colorized output for better readability
- **Schema Inference**: Automatically infer JSON Schema from configurations
## Installation
### From Source
```bash
cargo install --path .
```
### Pre-built Binaries
Download pre-built binaries from the [releases page](https://7000pct.gitea.bloupla.net/7000pctAUTO/config-forge/releases).
## Quick Start
### Convert a file
```bash
config-forge convert -i config.json -t yaml
config-forge convert -i config.yaml -t toml -o config.toml
```
### Validate against schema
```bash
config-forge validate -c config.json -s schema.json
config-forge validate -c config.yaml -S schema.yaml --schema-format file
```
### Generate TypeScript interfaces
```bash
config-forge generate-ts -i config.json -o config.ts
config-forge generate-ts -i config.json --interface-name AppConfig
```
### Batch conversion
```bash
config-forge batch -p "configs/**/*.json" -t yaml
config-forge batch -p "*.toml" -t json -o ./json_output
```
### Infer schema from config
```bash
config-forge infer -i config.json -o schema.json
```
## Usage
### Convert Command
Convert between configuration formats.
```bash
config-forge convert -i <input> [-f <from_format>] -t <to_format> [-o <output>] [--no-highlight]
```
**Options:**
- `-i, --input`: Input file path (required)
- `-f, --from`: Input format (auto-detected if not specified)
- `-t, --to`: Output format (required)
- `-o, --output`: Output file path (stdout if not specified)
- `--no-highlight`: Disable syntax highlighting
**Supported formats:** `json`, `yaml`, `toml`, `env`, `ini`
### Validate Command
Validate configuration against a JSON Schema.
```bash
config-forge validate -c <config> [-s <schema> | -S <schema-file>] [--schema-format <format>]
```
**Options:**
- `-c, --config`: Configuration file to validate (required)
- `-s, --schema`: Inline JSON Schema
- `-S, --schema-file`: Path to schema file
- `--schema-format`: Schema format (`inline` or `file`)
### Generate-TS Command
Generate TypeScript interfaces from configurations.
```bash
config-forge generate-ts -i <input> [-f <from_format>] [-o <output>] [-n <name>] [--export]
```
**Options:**
- `-i, --input`: Input file path (required)
- `-f, --from`: Input format (auto-detected if not specified)
- `-o, --output`: Output file path (stdout if not specified)
- `-n, --interface-name`: Interface name (default: filename)
- `--export`: Add export keyword
### Batch Command
Convert multiple files using glob patterns.
```bash
config-forge batch -p <pattern> -t <format> [-o <output_dir>] [--parallel] [--no-highlight]
```
**Options:**
- `-p, --pattern`: Glob pattern for input files (required)
- `-t, --to`: Output format (required)
- `-o, --output-dir`: Output directory (default: current directory)
- `--parallel`: Process files in parallel
- `--no-highlight`: Disable syntax highlighting
### Infer Command
Infer JSON Schema from a configuration file.
```bash
config-forge infer -i <input> [-f <from_format>] [-o <output>]
```
**Options:**
- `-i, --input`: Input file path (required)
- `-f, --from`: Input format (auto-detected if not specified)
- `-o, --output`: Output file path (stdout if not specified)
### Init Command
Create a default configuration file.
```bash
config-forge init [-o <output>]
```
**Options:**
- `-o, --output`: Output file path (default: `configforge.toml`)
### Global Options
- `--no-color`: Disable color output
- `-v, --verbose`: Enable verbose output
- `--help`: Show help information
- `--version`: Show version information
## Configuration
ConfigForge can be configured using a `configforge.toml` file in your project directory:
```toml
output_dir = "./"
default_format = "json"
color_output = true
parallel_processing = false
```
**Environment variables:**
- `CONFIG_FORGE_NO_COLOR`: Disable color output
- `CONFIG_FORGE_VERBOSE`: Enable verbose output
## Examples
### Convert JSON to YAML
```bash
config-forge convert -i app.json -t yaml
```
### Convert with custom output
```bash
config-forge convert -i config.toml -t json -o config.json
```
### Validate with inline schema
```bash
config-forge validate -c app.json -s '{"type": "object", "properties": {"name": {"type": "string"}}}'
```
### Generate TypeScript with custom name
```bash
config-forge generate-ts -i config.json -n AppConfig -o app.ts
```
### Batch convert with parallel processing
```bash
config-forge batch -p "**/*.toml" -t json --parallel
```
### Infer and save schema
```bash
config-forge infer -i config.yaml -o schema.json
```
## Building
```bash
cargo build
cargo build --release
```
## Testing
```bash
cargo test
cargo test --all
cargo clippy
cargo fmt --check
```
## Error Handling
| Error | Message | Solution |
|-------|---------|----------|
| UnsupportedFormat | Unsupported format 'xyz' | Check format spelling |
| FileNotFound | File 'path' not found | Verify file exists |
| ParseError | Failed to parse format | Check file syntax |
| ValidationError | Validation failed at path | Review schema requirements |
| SchemaParseError | Invalid JSON Schema | Verify schema syntax |
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.