I have a Cmd console set up to auto-complete card names for a Magic: the Gathering collection management system.
It uses the text parameter to query the database for car
I did override of the cmdloop function, and it was pretty straightforward. I didn't have to change anything else. Just copy the cmdloop function from the module (find code by doing import cmd
, cmd.__file__
), and add the two lines for changing delimiters:
try:
import readline
self.old_completer = readline.get_completer()
readline.set_completer(self.complete)
readline.parse_and_bind(self.completekey+": complete")
# do not use - as delimiter
old_delims = readline.get_completer_delims() # <-
readline.set_completer_delims(old_delims.replace('-', '')) # <-
except ImportError:
pass
That did it for me. In your case you may want to remove whichever delimiter is causing the issues.