Skip to content
oriontvvPublic

About

cli tool which can convert different formats

Topics

Resources

Code of conduct

Stars

36 stars

Watchers

1 watching

Forks

Repository files navigation

convfmt

Actions Status Coverage badge dependency status Crates.io

convfmt is a command line tool in rust which can convert between formats:

Usage:

$ convfmt --help
cli tool which can convert different formats

Usage: convfmt [OPTIONS] --from <FROM> --to <TO>

Options:
  -f, --from <FROM>         [possible values: bson, csv, dotenv, hjson, hocon, json, json5, jsonl, plist, ron, toml, toon, xml, yaml]
  -t, --to <TO>             [possible values: bson, csv, dotenv, hjson, hocon, json, json5, jsonl, plist, ron, toml, toon, xml, yaml]
  -c, --compact             Compress output if possible (default = false)
  -s, --sort-keys           Sort keys of objects (default = false)
  -i, --ignore-unsupported  Drop values the target format can't represent, e.g. `null` for toml (default = false)
  -h, --help                Print help
  -V, --version             Print version
$ cat cfg.yml | convfmt -f yaml -t toml > cfg.toml
$ convfmt -f json -t json < compact.json > pretty.json
$ convfmt -f json -t json --sort-keys < unordered.json > sorted.json
$ convfmt -f json -t toml --ignore-unsupported < with-nulls.json > cfg.toml
$ curl https://api.github.com/users/oriontvv | convfmt -f json -t json5 > api.json5

By default convfmt tries to use pretty format. Enable --compact option for compression.

By default the original order of keys is preserved. Enable --sort-keys option to sort keys of all objects (recursively) in alphabetical order.

Beware of nulls, some formats don't support them: toml fails to serialize a null and plist silently turns it into an empty string. Enable --ignore-unsupported option to drop such values.

Installation:

There are few ways:

brew install oriontvv/tap/convfmt
  • Download latest binary

  • Run it from docker without installing anything (-i is required, convfmt reads stdin)

$ cat cfg.yml | docker run --rm -i oriontvv/convfmt -f yaml -t toml > cfg.toml
  • Run or install it with nix (flakes required)
nix run github:oriontvv/convfmt -- -f yaml -t toml < cfg.yml
nix profile install github:oriontvv/convfmt
cargo install cargo-binstall && cargo binstall convfmt
cargo install --git https://github.com/oriontvv/convfmt

About

cli tool which can convert different formats

Topics

Resources

Code of conduct

Stars

36 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages