[Git][NTPsec/ntpsec][master] Add -W option for ntpq.

Eric S. Raymond gitlab at mg.gitlab.com
Fri Dec 23 12:29:14 UTC 2016


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


Commits:
eec1cec6 by Eric S. Raymond at 2016-12-23T07:07:21-05:00
Add -W option for ntpq.

- - - - -


2 changed files:

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


Changes:

=====================================
docs/includes/ntpq-body.txt
=====================================
--- a/docs/includes/ntpq-body.txt
+++ b/docs/includes/ntpq-body.txt
@@ -85,6 +85,9 @@ attempt to read interactive format commands from the standard input.
   Wide mode: if the host name or IP Address doesn't fit, write the
   full name/address and indent the next line so columns line up.
   The default truncates the name or address.
++-W+, +--width+::
+  Force the terminal width.  Only relevant for composition of the
+  peers display.
 
 == Internal Commands ==
 


=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -158,6 +158,7 @@ class Ntpq(cmd.Cmd):
         self.pktversion = ntp.magic.NTP_OLDVERSION + 1
         self.uservars = ntp.util.OrderedDict()
         self.ai_family = socket.AF_UNSPEC
+        self.termwidth = ntp.util.termsize()[1]
 
     def emptyline(self):
         "Called when an empty line is entered in response to the prompt."
@@ -275,7 +276,7 @@ usage: help [ command ]
         if not self.__dogetassoc():
             return
         if self.showhostnames:
-            termwidth = ntp.util.termsize().width
+            termwidth = interpreter.termwidth
         else:
             termwidth = None	# Default width
         report = ntp.util.PeerSummary(mode,
@@ -1490,18 +1491,21 @@ USAGE: ntpq [-46dphinOV] [-c str] [-D lvl] [host ...]
                                 peers
    -n no  numeric        numeric host addresses
    -V opt version        Output version information and exit
-   -w no  wide           enable wide display of addresses
+   -w no  wide           enable wide display of addresses / hosts
+                         on a separate line
+   -W no  width          force output width to this value instead of
+                         querying the terminal size
 '''
 
 if __name__ == '__main__':
     try:
         (options, arguments) = getopt.getopt(sys.argv[1:],
-                                             "46c:dD:hinpVw",
+                                             "46c:dD:hinpVwW:",
                                              ["ipv4","ipv6", "command=",
                                               "debug", "set-debug-level=",
                                               "help", "interactive", "numeric",
                                               "peers", "version",
-                                              "wide"])
+                                              "wide", "width="])
     except getopt.GetoptError as e:
         sys.stderr.write("%s\n" % e)
         sys.stderr.write(usage)
@@ -1544,6 +1548,8 @@ if __name__ == '__main__':
             raise SystemExit(0)
         elif switch in ("-w", "--wide"):
             interpreter.wideremote = True
+        elif switch in ("-W", "--width"):
+            interpreter.termwidth = int(val)
 
     if interpreter.interactive and len(interpreter.ccmds) > 0:
         interpreter.warn("%s: invalid option combination.\n" % progname)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/eec1cec66df1cff0b7e173cdf1cd3c458bd4bf1f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161223/6bf26767/attachment.html>


More information about the vc mailing list