Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maoertel/hoconvert
CLI tool to convert HOCON into valid JSON or YAML written in Rust.
https://github.com/maoertel/hoconvert
clap cli hocon json rust yaml
Last synced: 5 days ago
JSON representation
CLI tool to convert HOCON into valid JSON or YAML written in Rust.
- Host: GitHub
- URL: https://github.com/maoertel/hoconvert
- Owner: maoertel
- License: mit
- Created: 2021-10-23T11:22:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-11T07:15:11.000Z (over 1 year ago)
- Last Synced: 2024-10-13T18:59:01.877Z (about 1 month ago)
- Topics: clap, cli, hocon, json, rust, yaml
- Language: Rust
- Homepage:
- Size: 36.1 KB
- Stars: 33
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# {hocon:vert}
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.## Usage
```bash
hoconvert [input | --file ] [--output (yaml|json)]
```Either provide the hocon as first argument:
```bash
hoconvert "foo = bar"
```or provide it from `stdin`,
```bash
echo "foo = bar" | hoconvert
```which leads to the following output:
```json
{
"foo": "bar"
}
```You can also read the hocon from a file by providing the path:
```bash
hoconvert -f config.hocon
```Here is an example of a real-life Kubernetes problem as stated above:
```bash
kubectl get cm -o jsonpath='{.data.myHocon}' | jq -r | hoconvert | jq '.doWhatEverYouWant'
```## Installation
### Install with homebrew
In case you use `brew` you can install `hoconvert` as follows:
```bash
brew tap maoertel/tap
brew install hoconvert
```You can install from `brew` for the following architectures: `macOS/amd64`, `macOS/arm64` or `linux/amd64`.
### Download the binary
You can download a binary of the [latest release](https://github.com/maoertel/hoconvert/releases)
currently for `macOS/amd64`, `macOS/arm64` and `linux/amd64`.### Install with cargo
In case you have `cargo` installed this is the easiest way to install `hoconvert` from
[crates.io](https://crates.io/crates/hoconvert) in match to your underlying architecture:```bash
cargo install hoconvert
```### Build it yourself
Check this repo out, change into the project directory and run:
```bash
cargo build --release
```