docs: Make version option handling consistent

Document the help and version option handling, including long option
form, the same for all the command line tools, both in the their
help output and in any manpages. Add version option to randpkt.

Fix #15483
This commit is contained in:
John Thacker 2023-10-12 18:54:13 -04:00
parent 38d05ad97a
commit 8a422b5d02
16 changed files with 140 additions and 42 deletions

View File

@ -304,7 +304,7 @@ main(int argc, char **argv)
opt_dump_refs = 1;
break;
case 'v':
show_help_header(NULL);
show_version();
exit(EXIT_SUCCESS);
break;
case 'h':

View File

@ -55,6 +55,14 @@ capinfos - Prints information about capture files
<__infile__>
__...__
[manarg]
*capinfos*
*-h|--help*
[manarg]
*capinfos*
*-v|--version*
== DESCRIPTION
*Capinfos* is a program that reads one or more capture files and
@ -196,7 +204,7 @@ Displays additional capture file information.
-h|--help::
+
--
Prints the help listing and exits.
Print the version number and options and exit.
--
-H::
@ -397,7 +405,7 @@ latest packet seen.
-v|--version::
+
--
Displays the tool's version and exits.
Print the full version information and exit.
--
-x::

View File

@ -13,11 +13,17 @@ captype - Prints the types of capture files
[manarg]
*captype*
[ *-h* ]
[ *-v* ]
<__infile__>
__...__
[manarg]
*captype*
*-h|--help*
[manarg]
*captype*
*-v|--version*
== DESCRIPTION
*Captype* is a program that opens one or more capture files and

View File

@ -22,7 +22,6 @@ dumpcap - Dump network traffic
[ *-D*|*--list-interfaces* ]
[ *-f* <capture filter> ]
[ *-g* ]
[ *-h*|*--help* ]
[ *-i*|*--interface* <capture interface>|rpcap://<host>:<port>/<capture interface>|TCP@<host>:<port>|- ]
[ *-I*|*--monitor-mode* ]
[ *-k* <freq>,[<type>],[<center_freq1>],[<center_freq2>] ]
@ -39,7 +38,6 @@ dumpcap - Dump network traffic
[ *-S* ]
[ *-t* ]
[ *--temp-dir* <directory> ]
[ *-v*|*--version* ]
[ *-w* <outfile> ]
[ *-y*|*--linktype* <capture link type> ]
[ *--capture-comment* <comment> ]
@ -47,6 +45,14 @@ dumpcap - Dump network traffic
[ *--time-stamp-type* <type> ]
[ *--update-interval* <interval> ]
[manarg]
*dumpcap*
*-h|--help*
[manarg]
*dumpcap*
*-v|--version*
== DESCRIPTION
*Dumpcap* is a network traffic dump tool. It lets you capture packet
@ -231,7 +237,7 @@ user's group).
-h|--help::
+
--
Print the version and options and exits.
Print the version number and options and exit.
--
-i|--interface <capture interface>|rpcap://<host>:<port>/<capture interface>|TCP@<host>:<port>|-::
@ -463,7 +469,7 @@ typically defaults to __%USERPROFILE%\AppData\Local\Temp__.
-v|--version::
+
--
Print the version and exit.
Print the full version information and exit.
--
-w <outfile>::

View File

@ -249,7 +249,7 @@ is the *pcapng* format.
-h|--help::
+
--
Prints the version and options and exits.
Print the version number and options and exit.
--
-i <seconds per file>::
@ -412,7 +412,7 @@ packet, you will need od(1)/xref:text2pcap.html[text2pcap](1).
-v|--version::
+
--
Print the version and exit.
Print the full version information and exit.
--
-V::

View File

@ -93,7 +93,7 @@ available output formats. By default this is the *pcapng* format.
-h|--help::
+
--
Prints the version and options and exits.
Print the version number and options and exit.
--
-I <IDB merge mode>::
@ -143,7 +143,7 @@ frames were used).
-v|--version::
+
--
Print the version and exit.
Print the full version information and exit.
--
-V::

View File

@ -20,6 +20,14 @@ randpkt - Random packet generator
[ *-t* <type> ]
<filename>
[manarg]
*randpkt*
*-h|--help*
[manarg]
*randpkt*
*-v|--version*
== DESCRIPTION
*randpkt* is a small utility that creates a trace file full of random packets.
@ -72,6 +80,12 @@ available output formats. Note that not all output formats support
all packet types.
--
-h|--help::
+
--
Print the version number and options and exit.
--
-r::
+
--
@ -112,6 +126,12 @@ Defines the type of packet to generate:
usb-linux Universal Serial Bus with Linux specific header
--
-v|--version::
+
--
Print the full version information and exit.
--
include::diagnostic-options.adoc[]
== EXAMPLES

View File

@ -15,7 +15,6 @@ rawshark - Dump and analyze raw pcap data
*rawshark*
[ *-d* <encap:linktype>|<proto:protoname> ]
[ *-F* <field to display> ]
[ *-h* ]
[ *-l* ]
[ *-m* <bytes> ]
[ *-o* <preference setting> ] ...
@ -24,9 +23,16 @@ rawshark - Dump and analyze raw pcap data
[ *-R* <read (display) filter> ]
[ *-s* ]
[ *-S* <field format> ]
[ *-v* ]
[ *options* ]
[manarg]
*rawshark*
*-h|--help*
[manarg]
*rawshark*
*-v|--version*
== DESCRIPTION
*Rawshark* reads a stream of packets from a file or pipe, and prints a line
@ -132,10 +138,10 @@ multiple times in a given packet. A single field may be specified per *-F*
flag. If you want to apply a display filter, use the *-R* flag.
--
-h::
-h|--help::
+
--
Print the version and options and exits.
Print the version number and options and exit.
--
-l::
@ -226,10 +232,10 @@ For something similar to Wireshark's standard display ("Type: A (1)") you
could use *%D: %S (%N)*.
--
-v::
-v|--version::
+
--
Print the version and exit.
Print the full version information and exit.
--
include::dissection-options.adoc[tags=!tshark;!decode_as]

View File

@ -14,9 +14,16 @@ reordercap - Reorder input file by timestamp into output file
[manarg]
*reordercap*
[ *-n* ]
[ *-v* ]
<__infile__> <__outfile__>
[manarg]
*reordercap*
*-h|--help*
[manarg]
*reordercap*
*-v|--version*
== DESCRIPTION
*Reordercap* is a program that reads an input capture file and rewrites the
@ -41,6 +48,12 @@ the same way *reordercap* handles this.
== OPTIONS
-h|--help::
+
--
Print the version number and options and exit.
--
-n::
+
--
@ -48,10 +61,10 @@ When the *-n* option is used, *reordercap* will not write out the output
file if it finds that the input file is already in order.
--
-v::
-v|--version::
+
--
Print the version and exit.
Print the full version information and exit.
--
include::diagnostic-options.adoc[]

View File

@ -19,7 +19,6 @@ text2pcap - Generate a capture file from an ASCII hexdump of packets
[ *-e* <l3pid> ]
[ *-E* <encapsulation type> ]
[ *-F* <file format> ]
[ *-h* ]
[ *-i* <proto> ]
[ *-l* <typenum> ]
[ *-N* <intf-name> ]
@ -32,12 +31,19 @@ text2pcap - Generate a capture file from an ASCII hexdump of packets
[ *-t* <timefmt> ]
[ *-T* <srcport>,<destport> ]
[ *-u* <srcport>,<destport> ]
[ *-v* ]
[ *-4* <srcip>,<destip> ]
[ *-6* <srcip>,<destip> ]
<__infile__>|-
<__outfile__>|-
[manarg]
*text2pcap*
*-h|--help*
[manarg]
*text2pcap*
*-v|--version*
== DESCRIPTION
*Text2pcap* is a program that reads in an ASCII hex dump and writes the
@ -233,8 +239,8 @@ the file in several formats; *text2pcap -F* provides a list of the
available output formats. The default is the *pcapng* format.
--
-h::
Displays a help message.
-h|--help::
Print the version number and options and exit.
-i <proto>::
+
@ -373,8 +379,8 @@ are automatically also included with each packet.
Example: __-u1000,69__ to make the packets look like TFTP/UDP packets.
--
-v::
Print the version and exit.
-v|--version::
Print the full version information and exit.
-4 <srcip>,<destip>::
+

View File

@ -25,6 +25,14 @@ tshark - Dump and analyze network traffic
*tshark*
*-G* [ <report type> ] [ --elastic-mapping-filter <protocols> ]
[manarg]
*tshark*
*-h|--help*
[manarg]
*tshark*
*-v|--version*
== DESCRIPTION
*TShark* is a network protocol analyzer. It lets you capture packet
@ -574,7 +582,7 @@ Field 4:: False String
-h|--help::
+
--
Print the version and options and exit.
Print the version number and options and exit.
--
-H <input hosts file>::
@ -907,7 +915,7 @@ names.
-v|--version::
+
--
Print the version and exit.
Print the full version information and exit.
--
-V::

View File

@ -20,6 +20,14 @@ wireshark - Interactively dump and analyze network traffic
[ *options* ]
[ <infile> ]
[manarg]
*wireshark*
*-h|--help*
[manarg]
*wireshark*
*-v|--version*
== DESCRIPTION
*Wireshark* is a GUI network protocol analyzer. It lets you

View File

@ -34,6 +34,7 @@
#include <wsutil/wslog.h>
#include <wsutil/ws_getopt.h>
#include <wsutil/version_info.h>
#include "randpkt_core/randpkt_core.h"
@ -92,11 +93,17 @@ usage(gboolean is_error)
output = stderr;
}
fprintf(output, "Usage: randpkt [-b maxbytes] [-c count] [-t type] [-r] [-F output file type] filename\n");
fprintf(output, "Default max bytes (per packet) is 5000\n");
fprintf(output, "Default count is 1000.\n");
fprintf(output, "Default output file type is pcapng.\n");
fprintf(output, "-r: random packet type selection\n");
fprintf(output, "Usage: randpkt [options] <outfile>\n");
fprintf(output, "\n");
fprintf(output, "Options:\n");
fprintf(output, " -b maximum bytes per packet (default: 5000)\n");
fprintf(output, " -c packet count (default: 1000)\n");
fprintf(output, " -F output file type (default: pcapng)\n");
fprintf(output, " an empty \"-F\" option will list the file types\n");
fprintf(output, " -r select a different random type for each packet\n");
fprintf(output, " -t packet type\n");
fprintf(output, " -h, --help display this help and exit.\n");
fprintf(output, " -v, --version print version information and exit.\n");
fprintf(output, "\n");
fprintf(output, "Types:\n");
@ -110,7 +117,7 @@ usage(gboolean is_error)
g_strfreev(abbrev_list);
g_strfreev(longname_list);
fprintf(output, "\nIf type is not specified, a random packet will be chosen\n\n");
fprintf(output, "\nIf type is not specified, a random packet type will be chosen\n\n");
}
int
@ -142,6 +149,7 @@ main(int argc, char *argv[])
int ret = EXIT_SUCCESS;
static const struct ws_option long_options[] = {
{"help", ws_no_argument, NULL, 'h'},
{"version", ws_no_argument, NULL, 'v'},
{0, 0, 0, 0 }
};
@ -180,7 +188,9 @@ main(int argc, char *argv[])
create_app_running_mutex();
#endif /* _WIN32 */
while ((opt = ws_getopt_long(argc, argv, "b:c:F:ht:r", long_options, NULL)) != -1) {
ws_init_version_info("Randpkt", NULL, NULL);
while ((opt = ws_getopt_long(argc, argv, "b:c:F:ht:rv", long_options, NULL)) != -1) {
switch (opt) {
case 'b': /* max bytes */
produce_max_bytes = get_positive_int(ws_optarg, "max bytes");
@ -209,6 +219,7 @@ main(int argc, char *argv[])
break;
case 'h':
show_help_header(NULL);
usage(FALSE);
goto clean_exit;
break;
@ -217,6 +228,11 @@ main(int argc, char *argv[])
allrandom = TRUE;
break;
case 'v':
show_version();
goto clean_exit;
break;
case '?':
switch(ws_optopt) {
case 'F':

View File

@ -49,9 +49,9 @@ print_usage(FILE *output)
fprintf(output, "Usage: reordercap [options] <infile> <outfile>\n");
fprintf(output, "\n");
fprintf(output, "Options:\n");
fprintf(output, " -n don't write to output file if the input file is ordered.\n");
fprintf(output, " -h display this help and exit.\n");
fprintf(output, " -v print version information and exit.\n");
fprintf(output, " -n don't write to output file if the input file is ordered.\n");
fprintf(output, " -h, --help display this help and exit.\n");
fprintf(output, " -v, --version print version information and exit.\n");
}
/* Remember where this frame was in the file */

View File

@ -312,6 +312,7 @@ sharkd_init(int argc, char **argv)
break;
case 'h':
show_help_header("Daemon variant of Wireshark");
print_usage(stderr);
exit(0);
break;

View File

@ -268,8 +268,8 @@ print_usage (FILE *output)
fprintf(output, "\n"
"Miscellaneous:\n"
" -h display this help and exit\n"
" -v print version information and exit\n"
" -h, --help display this help and exit\n"
" -v, --version print version information and exit\n"
" -q don't report processed packet counts\n"
"");
}