nft: rearrange help output to group related options together
PATCH 1/1 nft: rearrange help output to group related options together
It has been reported that nft options are a bit chaotic. With a growing list of options for the nft CLI, we can do better when presenting them to the user who requests help.
This patch introduces a textual output grouping for options, in 4 groups:
* Options (general) -- common Unix utility options
* Options (operative) -- the options that modify the operative behaviour of nft
* Options (translation) -- output text modifiers for data translation
* Options (parsing) -- output text modifiers for parsing and other operations
There is no behavior change in this patch, is mostly a cosmetic change in the hope that users will find the nft tool a bit less confusing to use.
Before this patch, the help output was:
=== 8< ===
% nft --help
Usage: nft [ options ] [ cmds... ]
Options:
-h, help Show this help -v, version Show version information -V Show extended version information
-c, check Check commands validity without actually applying the changes. -f, file <filename> Read input from <filename> -i, interactive Read input from interactive CLI
-n, numeric Print fully numerical output. -s, stateless Omit stateful information of ruleset. -N, reversedns Translate IP addresses to names. -S, service Translate ports to service names as described in /etc/services. -I, includepath <directory> Add <directory> to the paths searched for include files. Defaul[..] -d, debug <level [,level...]> Specify debugging level (scanner, parser, eval, netlink, mnl, p[..] -a, handle Output rule handle. -e, echo Echo what has been added, inserted or replaced. -j, json Format output in JSON -u, guid Print UID/GID as defined in /etc/passwd and /etc/group. -y, numeric-priority Print chain priority numerically. -p, numeric-protocol Print layer 4 protocols numerically. -T, numeric-time Print time values numerically. -t, terse Omit contents of sets.
=== 8< ===
After this patch, the help output is:
=== 8< ===
% nft --help
Usage: nft [ options ] [ cmds... ]
Options (general):
-h, help Show this help -v, version Show version information -V Show extended version information
Options (with operative meaning):
-c, check Check commands validity without actually applying the changes. -f, file <filename> Read input from <filename> -i, interactive Read input from interactive CLI -I, includepath <directory> Add <directory> to the paths searched for include files. Defaul[..]
Options (output text modifiers for data translation):
-N, reversedns Translate IP addresses to names. -S, service Translate ports to service names as described in /etc/services. -u, guid Print UID/GID as defined in /etc/passwd and /etc/group. -n, numeric Print fully numerical output. -y, numeric-priority Print chain priority numerically. -p, numeric-protocol Print layer 4 protocols numerically. -T, numeric-time Print time values numerically.
Options (output text modifiers for parsing and other operations):
-d, debug <level [,level...]> Specify debugging level (scanner, parser, eval, netlink, mnl, p[..]
-e, echo Echo what has been added, inserted or replaced. -s, stateless Omit stateful information of ruleset. -a, handle Output rule handle. -j, json Format output in JSON -t, terse Omit contents of sets.
=== 8< ===
While at it, refresh the man page to better reflex this new grouping, and add some missing options.
---
v2: code formatting.
doc/nft.txt | 86 ++++++++++++++++++++++--------------- src/main.c | 139 +++++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 138 insertions(+), 87 deletions(-)
doc/nft.txt +52 -34
@@ -22,7 +22,10 @@ for Netfilter. OPTIONS ------- -For a full summary of options, run *nft --help*. +The command accepts several different options which are documented here in groups for better +understanding of their meaning. You can get information about options by running *nft --help*. + +.General options, common Unix utility options: *-h*:: *--help*::
@@ -32,13 +35,30 @@ For a full summary of options, run *nft --help*. *--version*:: Show version. -*-n*:: -*--numeric*:: - Print fully numerical output. +*-V*:: + Show long version information, including compile-time configuration. -*-s*:: -*--stateless*:: - Omit stateful information of rules and stateful objects. +.Operative options, options that modify the operative behavior of nft: + +*-c*:: +*--check*:: + Check commands validity without actually applying the changes. + +*-f*:: +*--file 'filename'*:: + Read input from 'filename'. If 'filename' is -, read from stdin. + +*-i*:: +*--interactive*:: + Read input from an interactive readline CLI. You can use quit to exit, or use the EOF marker, + normally this is CTRL-D. + +*-I*:: +*--includepath directory*:: + Add the directory 'directory' to the list of directories to be searched for included files. This + option may be specified multiple times. + +.Output text modifiers options for data translation: *-N*:: *--reversedns*::
@@ -53,49 +73,47 @@ For a full summary of options, run *nft --help*. *--guid*:: Translate numeric UID/GID to names as defined by /etc/passwd and /etc/group. -*-p*:: -*--numeric-protocol*:: - Display layer 4 protocol numerically. +*-n*:: +*--numeric*:: + Print fully numerical output. *-y*:: *--numeric-priority*:: Display base chain priority numerically. -*-c*:: -*--check*:: - Check commands validity without actually applying the changes. +*-p*:: +*--numeric-protocol*:: + Display layer 4 protocol numerically. -*-a*:: -*--handle*:: - Show object handles in output. +*-T*:: +*--numeric-time*:: + Show time, day and hour values in numeric format. + +.Output text modifiers options for parsing and other operations: + +*-d*:: +*--debug* 'level':: + Enable debugging output. The debug level can be any of *scanner*, *parser*, *eval*, + *netlink*, *mnl*, *proto-ctx*, *segtree*, *all*. You can combine more than one by + separating by the ',' symbol, for example '-d eval,mnl'. *-e*:: *--echo*:: When inserting items into the ruleset using *add*, *insert* or *replace* commands, print notifications just like *nft monitor*. +*-s*:: +*--stateless*:: + Omit stateful information of rules and stateful objects. + +*-a*:: +*--handle*:: + Show object handles in output. + *-j*:: *--json*:: Format output in JSON. See libnftables-json(5) for a schema description. -*-I*:: -*--includepath directory*:: - Add the directory 'directory' to the list of directories to be searched for included files. This - option may be specified multiple times. - -*-f*:: -*--file 'filename'*:: - Read input from 'filename'. If 'filename' is -, read from stdin. - -*-i*:: -*--interactive*:: - Read input from an interactive readline CLI. You can use quit to exit, or use the EOF marker, - normally this is CTRL-D. - -*-T*:: -*--numeric-time*:: - Show time, day and hour values in numeric format. - *-t*:: *--terse*:: Omit contents of sets from output.
src/main.c +86 -53
175 lines not on this page · raw message