hof / fmt

hof/fmt is a command which will format any and all languages. You can create your own formatters as well.

hof needs a code formatter for the languages it generates. It runs the pre-output through before applying diff and merging with any custom code you added to output files. This is simplifies the job of template authors, but is also required to avoid unnecessary merge conflicts.

You will need Docker available to use this feature. Hof will pull and run containers in the background. You can disable this by setting an environment variable.


$ hof help fmt

With hof fmt, you can
  1. format any language from a single tool
  2. run formatters as api servers for IDEs and hof
  3. manage the underlying formatter containers

  hof fmt [filepaths or globs] [flags]
  hof fmt [command]

Available Commands:
  info        get formatter info
  pull        docker pull a formatter
  start       start a formatter
  stop        stop a formatter
  test        test that formatter(s) are working

      --fmt-data   include cue,yaml,json,toml,xml files, set to false to disable (default true)
  -h, --help       help for fmt

Global Flags:
  -E, --all-errors           print all available errors
  -i, --ignore-errors        turn off output and assume defaults at prompts
  -D, --include-data         auto include all data files found with cue files
  -V, --inject-env           inject all ENV VARs as default tag vars
  -I, --input stringArray    extra data to unify into the root value
  -p, --package string       the Cue package context to use during execution
  -l, --path stringArray     CUE expression for single path component when placing data files
  -q, --quiet                turn off output and assume defaults at prompts
  -d, --schema stringArray   expression to select schema to apply to data files
      --stats                print generator statistics
  -0, --stdin-empty          A flag that ensure stdin is zero and does not block
  -t, --tags stringArray     @tags() to be injected into CUE code
  -v, --verbosity int        set the verbosity of output
      --with-context         add extra context for data files, usable in the -l/path flag

Use "hof fmt [command] --help" for more information about a command.