hornet fmt¶
Reformat a named.conf file in-place using Hornet's canonical style.
Usage¶
hornet fmt [OPTIONS] <FILE>
Arguments:
<FILE> Path to named.conf
Options:
-i, --indent <N> Indent size in spaces [default: 4]
--check Check formatting only; exit 1 if file would change (comments are ignored)
--modern Use modern keyword aliases [default: true]
--no-modern Keep legacy keywords
--force Rewrite the file even though its comments will be removed
-h, --help Print help
Examples¶
Reformat in-place¶
Output:
Check-only mode (CI / pre-commit)¶
Output when already formatted:
Output when reformatting would change the file (exits 1):
Files with comments¶
Hornet does not preserve comments, so rewriting a file deletes them. fmt
refuses to do that silently: on a file with comments it exits 1 and leaves
the file untouched.
error: /etc/bind/named.conf contains comments, which hornet does not preserve; rewriting it would delete them. Re-run with --force to rewrite anyway.
To rewrite it anyway:
warning: /etc/bind/named.conf: comments were removed (hornet does not preserve comments)
Formatted /etc/bind/named.conf
--check ignores comments: a file that is formatted apart from its comments
passes, with a note on stderr:
info: /etc/bind/named.conf: comments are ignored by --check
OK /etc/bind/named.conf is already formatted
Comment markers inside quoted strings (file "db#1";) are data, not comments.
Use 2-space indent¶
Preserve legacy keywords¶
Exit codes¶
| Code | Meaning |
|---|---|
0 |
Success (file formatted, or --check and file was already correct) |
1 |
Parse error; file has comments and --force was not given; or --check and file would have been changed |
CI integration¶
# GitHub Actions: fail if any config file is not formatted
- name: Check BIND9 formatting
run: hornet fmt --check /etc/bind/named.conf
Notes¶
- Without
--check, the file is overwritten with the formatted output. - Comments are not preserved; a file with comments is only rewritten with
--force. - Always run
hornet checkafterfmtto ensure the reformatted file is also semantically valid. fmtonly handlesnamed.conffiles. Zone files do not have a canonical format in Hornet yet.