This is a rather basic file formatting tool based on jq, yq and GNU Make that can be used to format YAML and JSON files. Both tools have to be installed for this to actually work.
- Grab the simple-formatter.sh from this repo and place it somewhere
- Make sure that
make
,jq
andyq
are installed and available in thePATH
Pass at least one file that should be formatted
simple-formatter.sh ./a/folder/some.json
It will also accept glob patterns like
simple-formatter.sh /some/folder/*
This currently handles JSON & YAML, with the help of JQ and YQ.
The number of parallel jobs can be influenced with the JOBS environment variable. It will default to whatever “nproc –all” returns.
Debug output can be enabled by setting the DEBUG environment variable to 1
The bash script uses Makes parallel execution to increase performance. It will create a Makefile with the help of mktemp
and then call that with the files given to it.
The makefile will then generate a temporary file for every file to be formatted, run jq/yq on the input file and write the output to the temporary file. It will then move the temporary file to the input file, overriding it in the process.
nope