[Git][NTPsec/ntpsec][master] Address GitLab issue #65: ntpd and ntpq have no command line help option.

Eric S. Raymond gitlab at mg.gitlab.com
Fri Jun 3 01:55:53 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
bf1e82de by Eric S. Raymond at 2016-06-02T21:54:03-04:00
Address GitLab issue #65: ntpd and ntpq have no command line help option.

Adds and documents help option for ntpq.

- - - - -


2 changed files:

- docs/includes/ntpq-body.txt
- ntpq/ntpq.c


Changes:

=====================================
docs/includes/ntpq-body.txt
=====================================
--- a/docs/includes/ntpq-body.txt
+++ b/docs/includes/ntpq-body.txt
@@ -66,6 +66,8 @@ attempt to read interactive format commands from the standard input.
   Increase debugging level by 1.
 +-D+ num, +--set-debug-level+=num::
   The debug level is set to the following numeric argument.
++-h+, +--help+::
+  Print a usage message summarizing options.
 +-i+, +--interactive+::
   Force +{ntpq}+ to operate in interactive mode. Prompts will be written
   to the standard output and commands read from the standard input.


=====================================
ntpq/ntpq.c
=====================================
--- a/ntpq/ntpq.c
+++ b/ntpq/ntpq.c
@@ -411,6 +411,7 @@ static const struct option longoptions[] = {
     { "command",	    1, 0, 'c' },
     { "debug",		    0, 0, 'd' },
     { "set-debug-level",    1, 0, 'D' },
+    { "help",               0, 0, 'h' },
     { "interactive",        0, 0, 'i' },
     { "numeric",            0, 0, 'n' },
     { "old-rv",             0, 0, 'O' },
@@ -443,6 +444,36 @@ main(
 #endif
 
 #ifndef BUILD_AS_LIB
+static void ntpq_usage(void)
+{
+#define P(x)	fputs(x, stderr)
+    P("USAGE: ntpq [-46dphinOV] [-c str] [-D lvl] [ host ...]\n");
+    P("  Flg Arg Option-Name    Description\n");
+    P("   -4 no  ipv4           Force IPv4 DNS name resolution\n");
+    P("				- prohibits the option 'ipv6'\n");
+    P("   -6 no  ipv6           Force IPv6 DNS name resolution\n");
+    P("				- prohibits the option 'ipv4'\n");
+    P("   -c Str command        run a command and exit\n");
+    P("				- may appear multiple times\n");
+    P("   -d no  debug-level    Increase output debug message level\n");
+    P("				- may appear multiple times\n");
+    P("   -D Str set-debug-level Set the output debug message level\n");
+    P("				- may appear multiple times\n");
+    P("   -h no  help           Print a usage message.\n");
+    P("   -p no  peers          Print a list of the peers\n");
+    P("				- prohibits the option 'interactive'\n");
+    P("   -i no  interactive    Force ntpq to operate in interactive mode\n");
+    P("				- prohibits these options:\n");
+    P("				command\n");
+    P("				peers\n");
+    P("   -n no  numeric        numeric host addresses\n");
+    P("   -O no  old-rv         Always output status line with readvar\n");
+    P("   -V opt version        Output version information and exit\n");
+    P("   -w no  wide           enable wide display of addresses\n");
+#undef P
+}
+
+
 int
 ntpqmain(
 	int argc,
@@ -522,6 +553,10 @@ ntpqmain(
 			debug = atoi(ntp_optarg);
 #endif
 			break;
+		    case 'h':
+			ntpq_usage();
+			exit(0);
+			break;
 		    case 'i':
 			opt_interactive = true;
 			break;
@@ -540,9 +575,10 @@ ntpqmain(
 		    case 'w':
 			opt_wide = true;
 			break;
-		    default :
+		    default:
 			/* chars not in table get converted to ? */
 			printf("Unknown command line switch or missing argument.\n");
+			ntpq_usage();
 			exit(1);
 		    } /*switch*/
 		}



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/bf1e82de8ea2940bae695f01cf9f59e63d5b48a7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160603/2bff8bc2/attachment.html>


More information about the vc mailing list