Are there best-practices for creating wizards or asking various questions (whether yes/no or text/numeric entry) in a cmd.Cmd class? Something like the imaginary confirm() and get_string() methods here:

  class MyCmd(cmd.Cmd):
    def do_name(self,line):
      s = get_string(prompt=line, default="Whatever")
      ...
    def do_save(self,line):
      if os.path.isfile(line):
        if not confirm("%r exists. Continue?", True): return
      self.save(line)
    def save(self, filename):
      ...

I can monkey with printing messages and using raw_input(), but I'd like to know if there's a better way (such as something interacting with readline for text-entry-with-history-and-completion, or raw-character input for Y/N answers rather than the need to hit <enter>, making it feel more uniform),

Thanks,

-tkc


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to