Commit 5fbc32d4 authored by Seblu's avatar Seblu
Browse files

fix prompt editon in expert mode

parent bb1bd477
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -24,9 +24,9 @@ from sjrpc.core.exceptions import *
class Cli(object):
    def __init__(self, settings):
        self.settings = settings
        self.prompt = "> "
        self.rpc = None
        self.alias = Alias()
        self.prompt = ""

    def start(self, line=""):
        '''Start a CLI'''
@@ -50,6 +50,15 @@ class Cli(object):
        self._connect()
        # auth
        self._auth()
        # set prompt
        if self.interactive:
            self.prompt = "%s%s%s%s>%s%s%s "%(color["["],
                                              color["light"],
                                              color["]"],
                                              self.settings["login"],
                                              color["["],
                                              color["reset"],
                                              color["]"])
        # parsing
        self._parse()
        # save history
@@ -84,14 +93,10 @@ class Cli(object):

    def _parse(self):
        '''Parse a line'''
        if self.interactive:
            prompt = "\001%s\002%s>\001%s\002 "%(color["light"],self.settings["login"],color["reset"])
        else:
            prompt = ""
        while True:
            try:
                try:
                    argv = shlex.split(self.printer.getline(prompt), comments=True)
                    argv = shlex.split(self.printer.getline(self.prompt), comments=True)
                except ValueError as e:
                    self.printer.error("Lexer: %s"%str(e))
                    continue
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ color = {
    # others
    "light": "\033[1m",
    "reset": "\033[m",
    "[": "\001",
    "]": "\002",
    }