aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2010-03-08 16:42:14 +0000
committerRob Austein <sra@hactrn.net>2010-03-08 16:42:14 +0000
commitae16a9a61c2b65388ecf41d85fb659c827e76fcc (patch)
tree2a5d56a6e868d6145be117b22b1c1632cd24f419
parent9528e51624378d89a57929f4276b150cfa123efc (diff)
Tweak completion to behave as a bash user would expect.
svn path=/rpkid/rpki/cli.py; revision=3042
-rw-r--r--rpkid/rpki/cli.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/rpkid/rpki/cli.py b/rpkid/rpki/cli.py
index d5a0ca71..2443e1b3 100644
--- a/rpkid/rpki/cli.py
+++ b/rpkid/rpki/cli.py
@@ -18,7 +18,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import cmd, glob
+import cmd, glob, os.path
try:
import readline
@@ -61,7 +61,20 @@ class Cmd(cmd.Cmd):
cmd.Cmd.emptyline(self)
def filename_complete(self, text, line, begidx, endidx):
- return glob.glob(text + "*")
+ result = glob.glob(text + "*")
+ if len(result) == 1:
+ path = result.pop()
+ if os.path.isdir(path) or (os.path.islink(path) and os.path.isdir(os.path.join(path, "."))):
+ result.append(path + os.path.sep)
+ else:
+ result.append(path + " ")
+ return result
+
+ def completenames(self, *args):
+ result = set(cmd.Cmd.completenames(self, *args))
+ if len(result) == 1:
+ result.add(result.pop() + " ")
+ return list(result)
if have_readline: