[Git][NTPsec/ntpsec][master] Do exact matches for help commands before searching for partial matches
Eric S. Raymond
gitlab at mg.gitlab.com
Fri Dec 2 06:54:46 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
2ab0e14a by Matt Selsky at 2016-12-02T01:53:07-05:00
Do exact matches for help commands before searching for partial matches
Fixes GitLab issue #182
- - - - -
1 changed file:
- ntpq/ntpq
Changes:
=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -198,27 +198,29 @@ class Ntpq(cmd.Cmd):
if cmd == "help" and arg:
helptext = 'help_'+arg
- argprefixlist = [a[5:] for a in self.get_names() if a.startswith(helptext)]
- if len(argprefixlist) == 1:
- line = line.replace(arg, argprefixlist.pop())
- elif len(argprefixlist) > 1:
- self.warn("Command `%s' is ambiguous\n" % arg)
- return
- elif len(argprefixlist) == 0:
- self.warn("Command `%s' is unknown\n" % arg)
- return
+ if helptext not in self.get_names():
+ argprefixlist = [a[5:] for a in self.get_names() if a.startswith(helptext)]
+ if len(argprefixlist) == 1:
+ line = line.replace(arg, argprefixlist.pop())
+ elif len(argprefixlist) > 1:
+ self.warn("Command `%s' is ambiguous\n" % arg)
+ return
+ elif len(argprefixlist) == 0:
+ self.warn("Command `%s' is unknown\n" % arg)
+ return
self.onecmd(line)
def do_help(self, arg):
if arg:
helptext = 'help_'+arg
- argprefixlist = [a[5:] for a in self.get_names() if a.startswith(helptext)]
- if len(argprefixlist) == 1:
- arg = argprefixlist.pop()
- elif len(argprefixlist) > 1:
- self.warn("Command `%s' is ambiguous\n" % arg)
- return
+ if helptext not in self.get_names():
+ argprefixlist = [a[5:] for a in self.get_names() if a.startswith(helptext)]
+ if len(argprefixlist) == 1:
+ arg = argprefixlist.pop()
+ elif len(argprefixlist) > 1:
+ self.warn("Command `%s' is ambiguous\n" % arg)
+ return
cmd.Cmd.do_help(self, arg)
def say(self, msg):
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/2ab0e14adf3106208cf101dc0ef476cdb18685e5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161202/fefcd2a5/attachment.html>
More information about the vc
mailing list