T
Tim Chase
I have sub-classes of cmd.Cmd in an arrangement somewhat like
class Config(cmd.Cmd):
def do_foo(self, line): print "Fooing %r" % line
def complete_foo(self, text, line, begidx, endidx):
...
class MyTUI(cmd.Cmd):
def __init__(self, configger=Config, *args, **kwargs):
cmd.Cmd.__init__(self, *args, **kwargs)
self.config = configger()
def complete_config(self, text, line, begidx, endidx):
magic_here(self.config, text, line, begidx, endidx)
I've been sparring with getting MyTUI.complete_config() to reach
into self.config for completions so I can type things like
(cmd) config <tab>
(cmd) config foo <tab>
and have it suggest from Config as if I had done something like
def do_config(self, line)
self.config.cmdloop()
and then asked for completions. That would mean that the first
one would act like Config.completenames() and the second one
would act like Config.complete_foo(...)
Is there a best way to get this pass-along behavior?
Thanks,
-tkc
class Config(cmd.Cmd):
def do_foo(self, line): print "Fooing %r" % line
def complete_foo(self, text, line, begidx, endidx):
...
class MyTUI(cmd.Cmd):
def __init__(self, configger=Config, *args, **kwargs):
cmd.Cmd.__init__(self, *args, **kwargs)
self.config = configger()
def complete_config(self, text, line, begidx, endidx):
magic_here(self.config, text, line, begidx, endidx)
I've been sparring with getting MyTUI.complete_config() to reach
into self.config for completions so I can type things like
(cmd) config <tab>
(cmd) config foo <tab>
and have it suggest from Config as if I had done something like
def do_config(self, line)
self.config.cmdloop()
and then asked for completions. That would mean that the first
one would act like Config.completenames() and the second one
would act like Config.complete_foo(...)
Is there a best way to get this pass-along behavior?
Thanks,
-tkc