Eric S. Raymond
esr at thyrsus.com
Sat Nov 26 23:45:46 UTC 2016
Hal Murray <hmurray at megapathdsl.net>:
> esr at thyrsus.com said:
> >> The old ntpq used to accept any unique prefix of a command. The new
> >> version doesn't.
> > I was going to say tab completion is the closest we can come, then I thought
> > of a kludgy way to fix this by hacking the precmd method. It might not be
> > portable to Python 3, though. How important do you think this is?
> I think it's reasonably important.
> I had a script with commands wired in.
> I often type things like:
> ntpq -c mru
OK, there are two ways we can handle this.
If the set of prefixes in actual use is relatively small and stereotyped,
a handful of explicit aliases will do. It would be completely reasonable to
add "mru" as an alias for "mrulist", for example.
If it's not, the problem can be solved in general with a precommand hook
that looks at the first token on the line and does its own attempt at
a unique-prefix match, filling in the right command if it finds one.
There are two problems with this possibility. The more serious one is that
it requires introspecting on the members of our cmd.Cmd instance. That is
an unstable area of the Python API - it changed sigificantly between 2 and 3,
and might well change again in the future. It's the kind of thing where
yes, you can do it, but you're begging for a future maintainence problem
if you do.
The less serious, more general problem is simply that it adds complexity
and potential points of failure, something I am reluctant to do without
better reason than I presently think we have here.
Can you audit your script usage to find out what abbreviatons you
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
More information about the devel