7000pctAUTO 7a547e20fe
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / test (3.9) (push) Has been cancelled
CI / build (push) Has been cancelled
fix: resolve CI/CD test and lint failures
2026-02-03 05:31:49 +00:00

DataForge CLI

A CLI tool that converts and validates data formats (JSON, YAML, TOML) with schema validation using JSON Schema. Features include format conversion, schema validation, type checking, batch processing, and quiet mode for scripting.

Features

  • Format Conversion: Convert between JSON, YAML, and TOML formats
  • Schema Validation: Validate data against JSON Schema (draft-07, draft-2019-09)
  • Type Checking: Infer and validate data types
  • Batch Processing: Process multiple files with pattern matching
  • Quiet Mode: Minimal output for scripting and CI/CD integration

Installation

From Source

git clone https://github.com/dataforge/dataforge-cli
cd dataforge-cli
pip install -e .

Using pipx

pipx install dataforge-cli

Quick Start

Convert a file from JSON to YAML

dataforge convert input.json --to yaml -o output.yaml

Convert from YAML to TOML

dataforge convert config.yaml --to toml -o config.toml

Validate against a schema

dataforge validate data.json --schema schema.json

Type checking with schema inference

dataforge typecheck config.json --infer

Commands

convert

Convert a file from one format to another.

dataforge convert INPUT_FILE OUTPUT_FILE --from FORMAT --to FORMAT

Options:

  • --from, -f: Input format (json, yaml, toml)
  • --to, -t: Output format (required, json, yaml, toml)
  • --indent, -i: Indentation spaces (0 for compact)
  • --quiet, -q: Minimal output

validate

Validate a file against a JSON Schema.

dataforge validate INPUT_FILE --schema SCHEMA_FILE

Options:

  • --schema, -s: Path to JSON Schema file
  • --strict: Strict validation mode
  • --quiet, -q: Minimal output

typecheck

Check types in a data file.

dataforge typecheck INPUT_FILE

Options:

  • --infer: Infer schema from data
  • --quiet, -q: Minimal output

batch-convert

Convert multiple files.

dataforge batch-convert --from FORMAT --to FORMAT --pattern "*.json" --directory DIR

Options:

  • --from, -f: Input format (json, yaml, toml)
  • --to, -t: Output format (required)
  • --output-dir, -o: Output directory
  • --pattern, -p: File pattern for batch processing
  • --recursive, -r: Search recursively
  • --quiet, -q: Minimal output

batch-validate

Validate multiple files against a schema.

dataforge batch-validate --schema SCHEMA FILE1 FILE2 ...

Options:

  • --schema, -s: Path to JSON Schema file (required)
  • --pattern, -p: File pattern for batch processing
  • --recursive, -r: Search recursively
  • --quiet, -q: Minimal output

Examples

Converting with stdin/stdout

cat config.json | dataforge convert - --to yaml

Validation in CI/CD

dataforge validate config.json --schema schema.json --quiet
if [ $? -ne 0 ]; then
    echo "Validation failed!"
    exit 1
fi

Batch conversion

dataforge batch-convert --from json --to yaml --pattern "*.json" --output-dir converted/

Schema inference

dataforge typecheck data.json --infer > schema.json

Exit Codes

Code Description
0 Success / Validation passed
1 Error / Validation failed

Configuration

No configuration file required. All options are passed via command-line arguments.

Supported Formats

Format Extension Read Write
JSON .json Yes Yes
YAML .yaml, .yml Yes Yes
TOML .toml Yes Yes

Development

Setup

git clone https://github.com/dataforge/dataforge-cli
cd dataforge-cli
pip install -e ".[dev]"

Running Tests

pytest tests/ -v --cov=dataforge

Linting

ruff check dataforge tests

License

MIT License - see LICENSE for details.

Description
A CLI tool that converts and validates data formats (JSON, YAML, TOML) with schema validation using JSON Schema
Readme MIT 130 KiB
v1.0.0 Latest
2026-02-03 04:18:52 +00:00
Languages
Python 100%