Skip to content

Latest commit

 

History

History
34 lines (20 loc) · 1.41 KB

README.org

File metadata and controls

34 lines (20 loc) · 1.41 KB

Simple Formatter

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.

Installation

  • Grab the simple-formatter.sh from this repo and place it somewhere
  • Make sure that make, jq and yq are installed and available in the PATH

Usage

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

How does this work?

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.

Can I influence the formatting in any way?

nope