Regularize the help output of programs.
Only print to the standard output, and only give the version information, if a "print help" command-line option is specified. Otherwise, leave out the version information, and print to the standard error. Leave out the copyright information; it's extra cruft, and http://www.gnu.org/prep/standards/html_node/_002d_002dhelp.html doesn't say anything about it (and bash, at least, doesn't print it). Change-Id: Ic5029ccf96e096453f3bd38383cc2dd355542e8a Reviewed-on: https://code.wireshark.org/review/2789 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
66c342ed59
commit
6b3391c60a
22
dumpcap.c
22
dumpcap.c
|
@ -475,20 +475,8 @@ create_timestamp(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_usage(gboolean print_ver)
|
||||
print_usage(FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (print_ver) {
|
||||
output = stdout;
|
||||
fprintf(output,
|
||||
"Dumpcap (Wireshark) %s\n"
|
||||
"Capture network packets and dump them into a pcapng file.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
} else {
|
||||
output = stderr;
|
||||
}
|
||||
fprintf(output, "\nUsage: dumpcap [options] ...\n");
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "Capture interface:\n");
|
||||
|
@ -4534,7 +4522,11 @@ main(int argc, char *argv[])
|
|||
while ((opt = getopt_long(argc, argv, OPTSTRING, long_options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'h': /* Print help and exit */
|
||||
print_usage(TRUE);
|
||||
printf("Dumpcap (Wireshark) %s\n"
|
||||
"Capture network packets and dump them into a pcapng or pcap file.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
exit_main(0);
|
||||
break;
|
||||
case 'v': /* Show version and exit */
|
||||
|
@ -4679,7 +4671,7 @@ main(int argc, char *argv[])
|
|||
pcap_queue_packet_limit = 1000;
|
||||
}
|
||||
if (arg_error) {
|
||||
print_usage(FALSE);
|
||||
print_usage(stderr);
|
||||
exit_main(1);
|
||||
}
|
||||
|
||||
|
|
26
rawshark.c
26
rawshark.c
|
@ -189,22 +189,8 @@ int encap;
|
|||
GPtrArray *string_fmts;
|
||||
|
||||
static void
|
||||
print_usage(gboolean print_ver)
|
||||
print_usage(FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (print_ver) {
|
||||
output = stdout;
|
||||
fprintf(output,
|
||||
"Rawshark (Wireshark) %s\n"
|
||||
"Dump and analyze network traffic.\n"
|
||||
"See http://www.wireshark.org for more information.\n"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info());
|
||||
} else {
|
||||
output = stderr;
|
||||
}
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "Usage: rawshark [options] ...\n");
|
||||
fprintf(output, "\n");
|
||||
|
@ -643,7 +629,11 @@ main(int argc, char *argv[])
|
|||
g_ptr_array_add(disp_fields, g_strdup(optarg));
|
||||
break;
|
||||
case 'h': /* Print help and exit */
|
||||
print_usage(TRUE);
|
||||
printf("Rawshark (Wireshark) %s\n"
|
||||
"Dump and analyze network traffic.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
exit(0);
|
||||
break;
|
||||
case 'l': /* "Line-buffer" standard output */
|
||||
|
@ -764,7 +754,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
default:
|
||||
case '?': /* Bad flag - print usage message */
|
||||
print_usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
@ -807,7 +797,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (arg_error) {
|
||||
print_usage(FALSE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
26
tfshark.c
26
tfshark.c
|
@ -193,22 +193,8 @@ string_elem_print(gpointer data, gpointer not_used _U_)
|
|||
#endif
|
||||
|
||||
static void
|
||||
print_usage(gboolean print_ver)
|
||||
print_usage(FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (print_ver) {
|
||||
output = stdout;
|
||||
fprintf(output,
|
||||
"TFShark (Wireshark) %s\n"
|
||||
"Dump and analyze network traffic.\n"
|
||||
"See http://www.wireshark.org for more information.\n"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info());
|
||||
} else {
|
||||
output = stderr;
|
||||
}
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "Usage: tfshark [options] ...\n");
|
||||
fprintf(output, "\n");
|
||||
|
@ -1105,7 +1091,11 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'h': /* Print help and exit */
|
||||
print_usage(TRUE);
|
||||
printf("TFShark (Wireshark) %s\n"
|
||||
"Dump and analyze network traffic.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
return 0;
|
||||
break;
|
||||
case 'l': /* "Line-buffer" standard output */
|
||||
|
@ -1291,7 +1281,7 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
default:
|
||||
case '?': /* Bad flag - print usage message */
|
||||
print_usage(TRUE);
|
||||
print_usage(stderr);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
@ -1329,7 +1319,7 @@ main(int argc, char *argv[])
|
|||
print_packet_info = TRUE;
|
||||
|
||||
if (arg_error) {
|
||||
print_usage(FALSE);
|
||||
print_usage(stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
26
tshark.c
26
tshark.c
|
@ -283,22 +283,8 @@ list_read_capture_types(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_usage(gboolean print_ver)
|
||||
print_usage(FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (print_ver) {
|
||||
output = stdout;
|
||||
fprintf(output,
|
||||
"TShark (Wireshark) %s\n"
|
||||
"Dump and analyze network traffic.\n"
|
||||
"See http://www.wireshark.org for more information.\n"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info());
|
||||
} else {
|
||||
output = stderr;
|
||||
}
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "Usage: tshark [options] ...\n");
|
||||
fprintf(output, "\n");
|
||||
|
@ -1426,7 +1412,11 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'h': /* Print help and exit */
|
||||
print_usage(TRUE);
|
||||
printf("TShark (Wireshark) %s\n"
|
||||
"Dump and analyze network traffic.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
return 0;
|
||||
break;
|
||||
case 'l': /* "Line-buffer" standard output */
|
||||
|
@ -1649,7 +1639,7 @@ main(int argc, char *argv[])
|
|||
list_capture_types();
|
||||
break;
|
||||
default:
|
||||
print_usage(TRUE);
|
||||
print_usage(stderr);
|
||||
}
|
||||
return 1;
|
||||
break;
|
||||
|
@ -1739,7 +1729,7 @@ main(int argc, char *argv[])
|
|||
cmdarg_err("This version of TShark was not built with support for capturing packets.");
|
||||
#endif
|
||||
if (arg_error) {
|
||||
print_usage(FALSE);
|
||||
print_usage(stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1160,7 +1160,7 @@ file_quit_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
}
|
||||
|
||||
static void
|
||||
print_usage(gboolean print_ver) {
|
||||
print_usage(gboolean for_help_option) {
|
||||
|
||||
FILE *output;
|
||||
|
||||
|
@ -1168,14 +1168,12 @@ print_usage(gboolean print_ver) {
|
|||
create_console();
|
||||
#endif
|
||||
|
||||
if (print_ver) {
|
||||
if (for_help_option) {
|
||||
output = stdout;
|
||||
fprintf(output, "Wireshark %s\n"
|
||||
"Interactively dump and analyze network traffic.\n"
|
||||
"See http://www.wireshark.org for more information.\n"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info());
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
} else {
|
||||
output = stderr;
|
||||
}
|
||||
|
|
|
@ -204,21 +204,19 @@ void main_window_quit(void)
|
|||
|
||||
// xxx copied from ../gtk/main.c
|
||||
static void
|
||||
print_usage(gboolean print_ver) {
|
||||
print_usage(gboolean for_help_option) {
|
||||
FILE *output;
|
||||
|
||||
#ifdef _WIN32
|
||||
create_console();
|
||||
#endif
|
||||
|
||||
if (print_ver) {
|
||||
if (for_help_option) {
|
||||
output = stdout;
|
||||
fprintf(output, "Wireshark %s\n"
|
||||
"Interactively dump and analyze network traffic.\n"
|
||||
"See http://www.wireshark.org for more information.\n"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info());
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
} else {
|
||||
output = stderr;
|
||||
}
|
||||
|
@ -786,7 +784,7 @@ int main(int argc, char *argv[])
|
|||
cf_name = new QString(optarg);
|
||||
break;
|
||||
case '?':
|
||||
print_usage(TRUE);
|
||||
print_usage(FALSE);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue