mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
* Enhance front matter description for search * acl section * alloc section * config section * deployment section * eval section * job section * license section * namespace section * node section * node pool section * operator section * plugin section * quota section * recommendation section * scaling section * sentinel section * server section * service section * setup section * system section * tls section * var section * volume section * change reference to command reference * Apply suggestions from code review Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com> --------- Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com>
72 lines
1.8 KiB
Plaintext
72 lines
1.8 KiB
Plaintext
---
|
|
layout: docs
|
|
page_title: 'nomad fmt command reference'
|
|
description: |
|
|
The `nomad fmt` commands rewrites Nomad configuration and job specification
|
|
files to canonical format. Use this command to improve readability and enforce consistency of style in Nomad files.
|
|
---
|
|
|
|
# `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
|
|
|
|
```plaintext
|
|
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](https://github.com/hashicorp/hcl/blob/hcl2/README.md), 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
|
|
|
|
```shell-session
|
|
$ cat agent.hcl
|
|
server {
|
|
enabled = true
|
|
bootstrap_expect = 1
|
|
}
|
|
|
|
client {
|
|
enabled = true
|
|
}
|
|
```
|
|
|
|
```shell-session
|
|
$ nomad fmt
|
|
agent.hcl
|
|
```
|
|
|
|
```shell-session
|
|
$ cat agent.hcl
|
|
server {
|
|
enabled = true
|
|
bootstrap_expect = 1
|
|
}
|
|
|
|
client {
|
|
enabled = true
|
|
}
|
|
```
|