Skip to content

CLI tool to convert HOCON into valid JSON, YAML or TOML written in Rust.

License

Notifications You must be signed in to change notification settings

maoertel/hoconvert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

{hocon:vert}

CLI Tool to convert HOCON into valid JSON, YAML, or TOML.

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

hoconvert [input | --file <path>] [--output (json|yaml|toml)]

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 convert to YAML or TOML:

hoconvert "{ app = { name = test, port = 8080 } }" --output toml
[app]
name = "test"
port = 8080

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'

Installation

Install with homebrew

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, linux/amd64, or linux/arm64.

Download the binary

You can download a binary of the latest release for macOS/amd64, macOS/arm64, linux/amd64, linux/arm64, and Windows/amd64.

Install with cargo

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

Build it yourself

Check this repo out, change into the project directory and run:

cargo build --release

About

CLI tool to convert HOCON into valid JSON, YAML or TOML written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages