reteps/dockerfmt: Dockerfile format and parser. a modern dockfmt.

Date:

Share:

Dockerfile format and parser, and a modern version of dockfmt. Built on top of the internal buildkit parser.

Binaries are available from the releases page.

A updated version of the dockfmt. Uses the dockerfile parser from moby/buildkit and the shell formatter from mvdan/sh.

Usage:
  dockerfmt [Dockerfile] [flags]
  dockerfmt [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  version     Print the version number of dockerfmt

Flags:
  -c, --check         Check if the file(s) are formatted
  -h, --help          help for dockerfmt
  -i, --indent uint   Number of spaces to use for indentation (default 4)
  -n, --newline       End the file with a trailing newline
  -w, --write         Write the formatted output back to the file(s)

Use "dockerfmt [command] --help" for more information about a command.
  • The RUN parser currently doesn’t support grouping or semicolons in commands
  • No line wrapping is performed for long JSON commands
  • The # escape=X directive is not supported

Contributions are welcome!

RUN <"hello"
echo "world"
EOF
  • Support for basic inline comments in run steps:
RUN echo "hello" \
    # this is a comment
    && echo "world"
RUN echo "hello" \
    # this is a comment
    # that spans multiple lines
    && echo "world"

This is surprisingly non-trivial as we want to attach the comments to their position in the formatted output, but they are stripped by the parser beforehand.

The JS bindings are available in the js directory. More information on how to use them can be found in the README file.

Source link

Subscribe to our magazine

━ more like this

He Chunhui’s Tiny386 Turns the Humble ESP32-S3 Into a Fully-Functional 386-Powered Desktop PC

Developer He Chunhui has turned the humble Espressif ESP32 microcontroller into a fully-fledged '90s personal computer with Tiny386 — a resource-efficient emulator capable of...

22 Pictures of Cats Cozying Up by the Fire and Living Their Fluffiest, Toastiest Lives

When the weather turns cold, cats somehow always discover the warmest, coziest corner of the house usually right by the fireplace. They curl up...

Under-$100 Free People Gifts For Everyone On Your List

It’s pretty safe to say that we’re all on a budget and all short on time. The solution? Free People’s online gift shop. The...

Today’s NYT Strands Hints, Answer and Help for Nov. 9 #616

Looking for the most recent Strands answer? Click here for our daily Strands hints, as well as our daily answers and hints for The New...

William Sealy Gosset Plaque in Ireland

When William Sealy Gosset joined the Guinness brewery in Dublin in 1899 as a chemist, he faced a practical problem: how could he...