Itch

InTerCHanges one data format into another (get it?)

A very simple cli to convert between some of the most common plain-text data formats. It can't perform every conversion that might be theoretically possible, but it tries its best

Installation

itch currently does not offer binary downloads, and must instead be built from source. You can use rustup to get the rust toolchain, the run the following command to download and install itch:

bash cargo install --force --git https://github.com/FreddieRidell/itch.git

Overview

``` USAGE: itch [OPTIONS]

FLAGS: -h, --help Prints help information -V, --version Prints version information

OPTIONS: -f, --from Format of the input, will be derived if possible -i, --input Path to the input file, leave empty for stdin -o, --output Path to the output file, leave empty for stdout -t, --to Format of the output, will be derived if possible ```

itch can take input from a file or std in, and output to a file or std out. If given a file as input or output it will try to detect the format automatically. itch doesn't do any manipulation to data to satisfy the different constructs that different formats can express; so there's no guarantee that a conversion will work.

Formats

First Class

Can all be pretty reliably used as sources and targets

Second Class

Somewhat unreliable, but can be used for basic transformations

Behaviour

itch should always produce the same output when given the same input:

input

shell echo '<element key="value"><child/></element>' | itch -f xml -t json

output

json { "key": "value", "child": {} }

itch will not necessarily produce output that can automatically be reversed:

input

shell echo '<element key="value"><child/></element>' | itch -f xml -t json | itch -f json -t xml

output

xml <key>value</key><child></child>

Implementation

Uses serde and it's own internal data representation format to act as an intermediary between the different data formats:

rust enum Itch { Obj(IndexMap<String, Itch>), Array(Vec<Itch>), Bool(bool), Int(i64), Float(f64), Text(String), }

Each deserialization step converts to this type, and each serialisation step converts from it.