| Crates.io | hoconvert |
| lib.rs | hoconvert |
| version | 1.0.0 |
| created_at | 2021-10-29 20:36:50.605981+00 |
| updated_at | 2023-04-09 19:26:40.618825+00 |
| description | CLI tool to convert HOCON into valid JSON or YAML. |
| homepage | |
| repository | https://github.com/maoertel/hoconvert |
| max_upload_size | |
| id | 474181 |
| size | 60,008 |
CLI Tool to convert HOCON into valid JSON or YAML.
Under normal circumstances this is mostly not needed because hocon configs are parsed
within the application – case closed. But for example in conjunction with Kubernetes
where .conf files can reside in ConfigMaps there was that need to extract information
on command line from time to time. And what would be more comfortable than to use jq
for this.
hoconvert [input | --file <path>] [--output (yaml|json)]
Either provide the hocon as first argument:
hoconvert "foo = bar"
or provide it from stdin,
echo "foo = bar" | hoconvert
which leads to the following output:
{
"foo": "bar"
}
You can also read the hocon from a file by providing the path:
hoconvert -f config.hocon
Here is an example of a real-life Kubernetes problem as stated above:
kubectl get cm <any ConfigMap> -o jsonpath='{.data.myHocon}' | jq -r | hoconvert | jq '.doWhatEverYouWant'
In case you use brew you can install hoconvert as follows:
brew tap maoertel/tap
brew install hoconvert
You can install from brew for the following architectures: macOS/amd64, macOS/arm64 or linux/amd64.
You can download a binary of the latest release
currently for macOS/amd64, macOS/arm64 and linux/amd64.
In case you have cargo installed this is the easiest way to install hoconvert from
crates.io in match to your underlying architecture:
cargo install hoconvert
Check this repo out, change into the project directory and run:
cargo build --release