Nomad
nomad fmt command reference
The nomad fmt
command rewrites Nomad configuration and job specification files
to canonical format. Use this command to improve readability and enforce
consistency of style in Nomad files.
Usage
nomad fmt [options] paths ...
If a path is a directory, the command recursively formats all files with
.nomad
and .hcl
extensions in the directory. If you provide a single dash
(-) as an argument, the nomad fmt
command reads from standard input and
writes the processed text to standard output.
The nomad fmt
command checks the syntax against
HCL2, the second
generation of Hashicorp Configuration Language. Running this command with
deprecated HCL1 job specification results in errors.
nomad fmt
options
-check
: Check if the files are valid HCL files. If not, exit status of the command will be 1 and the incorrect files will not be formatted. This flag overrides any-write
flag value.-list
: List the files which contain formatting inconsistencies. Defaults to-list=true
.-recursive
: Process files in subdirectories. By default, only the given (or current) directory is processed.-write
: Overwrite the input files. Defaults to-write=true
.
Examples
$ cat agent.hcl
server {
enabled = true
bootstrap_expect = 1
}
client {
enabled = true
}
$ nomad fmt
agent.hcl
$ cat agent.hcl
server {
enabled = true
bootstrap_expect = 1
}
client {
enabled = true
}