• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Nomad
  • Install
  • Intro
  • Tutorials
  • Documentation
  • API
  • Tools
  • Plugins
  • Sign up
Nomad Home

Documentation

Skip to main content
  • Documentation

    • Overview
    • agent
    • agent-info
    • fmt
    • monitor
    • status
    • ui
    • version

  • Schedulers

  • Nomad Ecosystem
  • Nomad Partnerships
  • Who Uses Nomad
  • FAQ

  • Resources

  • Tutorial Library
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Nomad
  3. Documentation
  4. Commands (CLI)
  5. fmt
  • Nomad
  • v1.3.x
  • v1.2.x
  • v1.1.x
  • v1.0.x
  • v0.12.x
  • v0.11.x

»Command: fmt

The fmt commands check the syntax and rewrites Nomad configuration and jobspec files to canonical format. It can be used to improve readability and enforce consistency of style in Nomad files.

Usage

nomad fmt [flags] paths ...

Formats Nomad agent configuration and job file to a canonical format. If a path is a directory, it will recursively format all files with .nomad and .hcl extensions in the directory.

If you provide a single dash (-) as argument, fmt will read from standard input (STDIN) and output the processed output to standard output (STDOUT).

Format Options:

  • -list=false : Don't list the files, which contain formatting inconsistencies.
  • -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.
  • -write=false : Don't overwrite the input files.
  • -recursive : Process also files in subdirectories. By default only the given (or current) directory is processed.

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
}
Edit this page on GitHub

On this page

  1. Command: fmt
  2. Usage
  3. Format Options:
  4. Examples
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)