From c060fa2f90c5c7edec72254c9d0a0802a4850e2a Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 29 Jan 2026 15:13:09 +0000 Subject: [PATCH] Add core files: README, Cargo.toml, LICENSE --- README.md | 246 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 244 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac7308b..4d363d5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,245 @@ -# config-forge +# ConfigForge -A powerful CLI tool for converting between configuration formats (JSON, YAML, TOML, ENV, INI) with built-in validation, schema inference, and TypeScript interface generation. \ No newline at end of file +[![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. + +## 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 [-f ] -t [-o ] [--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 [-s | -S ] [--schema-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 [-f ] [-o ] [-n ] [--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 -t [-o ] [--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 [-f ] [-o ] +``` + +**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 ] +``` + +**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.