def render_prompt(context): rendered_prompt = constants.prompt if options.interactive and not options.batch: # TODO: fix how color interacts with readline, # seems the color prompt messes it up promptstr = "crm(%s)%s# " % (cib_prompt(), context.prompt()) constants.prompt = promptstr if clidisplay.colors_enabled(): rendered_prompt = term.render(clidisplay.prompt(promptstr)) else: rendered_prompt = promptstr return rendered_prompt
def help(cls, topic, helptxt): if cls.lasttopic == topic and \ time.time() - cls.laststamp < cls.timeout: return if helptxt: import readline cmdline = readline.get_line_buffer() print "\n%s" % helptxt if clidisplay.colors_enabled(): print "%s%s" % (term.render(clidisplay.prompt_noreadline(constants.prompt)), cmdline), else: print "%s%s" % (constants.prompt, cmdline), cls.laststamp = time.time() cls.lasttopic = topic
def help(cls, topic, helptxt): if cls.lasttopic == topic and \ time.time() - cls.laststamp < cls.timeout: return if helptxt: import readline cmdline = readline.get_line_buffer() print "\n%s" % helptxt if clidisplay.colors_enabled(): print "%s%s" % (term.render( clidisplay.prompt_noreadline(constants.prompt)), cmdline), else: print "%s%s" % (constants.prompt, cmdline), cls.laststamp = time.time() cls.lasttopic = topic
common_err(msg) usage(2) if options.interactive and not options.batch: context.setup_readline() rc = 0 while True: try: rendered_prompt = constants.prompt if options.interactive and not options.batch: # TODO: fix how color interacts with readline, # seems the color prompt messes it up promptstr = "crm(%s)%s# " % (cib_prompt(), context.prompt()) constants.prompt = promptstr if clidisplay.colors_enabled(): rendered_prompt = term.render(clidisplay.prompt(promptstr)) else: rendered_prompt = promptstr inp = utils.multi_input(rendered_prompt) if inp is None: if options.interactive: rc = 0 context.quit(rc) try: if not context.run(inp): rc = 1 except ValueError, msg: rc = 1 common_err(msg) except KeyboardInterrupt: