Consider the following Python 2.7 script:
#!/usr/bin/python
import cmd
class T(cmd.Cmd):
def completedefault(self, *a):
print 'completedefault called'
return []
t=T()
t.cmdloop()
When I expect:
I type a character into the shell, then hit tab, I expect to see "completedfault called" printed.
What actually happens:
I type a character into the shell, then hit tab, and nothing happens.
Tested with Python 2.7.3.
completedefault is called to complete a input line after you entered a command for which no complete_<commandname>-method is available.
Try this:
#!/usr/bin/python
import cmd
class T(cmd.Cmd):
def completedefault(self, *a):
print 'completedefault called'
return []
def test(self, *args):
print "test args: ", args
t=T()
t.cmdloop()
now enter test [space] and press tab, completedefault should be executed now.
If you want to control completion for command names, you can use completenames to do so, not completedefault.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With