6 Commits

Author SHA1 Message Date
Tim Gross
a0cbc1a26a cli: remove extraneous trailing newline from nomad fmt (#20318)
When `nomad fmt` writes to stdout instead of overwriting a file, the command was
using the `UI` output, which appends an extra newline. This results in extra
trailing newlines when using `nomad fmt` as part of a pipeline or editor plugin.

Update the command to write directly to stdout when in the stdout mode.

Fixes: https://github.com/hashicorp/nomad/issues/20307
2024-04-08 13:29:22 -04:00
hashicorp-copywrite[bot]
a9d61ea3fd Update copyright file headers to BUSL-1.1 2023-08-10 17:27:29 -05:00
hashicorp-copywrite[bot]
f005448366 [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
Tim Gross
68abcb80a0 cli: fmt -check should return early on diff (#16174)
The `nomad fmt -check` command incorrectly writes to file because we didn't
return before writing the file on a diff. Fix this bug and update the command
internals to differentiate between the write-to-file and write-to-stdout code
paths, which are activated by different combinations of options and flags.

The docstring for the `-list` and `-write` flags is also unclear and can be
easily misread to be the opposite of the actual behavior. Clarify this and fix
up the docs to match.

This changeset also refactors the tests quite a bit so as to make the test
outputs clear when something is incorrect.
2023-02-15 14:06:31 -05:00
Dao Thanh Tung
af56eb8b7f fix bug in nomad fmt -check does not return error code (#15797) 2023-01-17 09:15:34 -05:00
Damian Czaja
e4efedbbe4 cli: add nomad fmt (#14779) 2022-10-06 17:00:29 -04:00