Exemplo n.º 1
0
    def suggestCmd(self, cmdLine):
        cmds = cmdLine.split(' ')
        cmd = cmds[0]
        try:
            subcmd = cmds[1]
        except IndexError:
            subcmd = None

        param = None
        if (subcmd):
            try:
                param = cmds[2]
            except IndexError:
                pass

        if (cmd and (not subcmd)):  #only have command
            #try to suggest command
            suggestArr = []
            for c in utils.getCmdList():
                if (c[:len(cmd)] == cmd):
                    suggestArr.append(c)

            if (len(suggestArr) == 1
                ):  #now we got the only one correct command
                cmd = suggestArr[0]
                cmdLine = cmd + ' '
                if (self.text() == cmdLine):  #need suggest subcommand
                    self.suggestSubcmd(cmd, None)
                else:
                    self.setText(cmdLine)
                return
            elif (len(suggestArr) > 1):  #output all possible cmds
                cmd = self._suggest(cmd, suggestArr)
                cmdLine = cmd
                self.setText(cmdLine)
                utils.output(suggestArr)
                return

        #now we have command and subcommand
        if (subcmd and (not param)):
            self.suggestSubcmd(cmd, subcmd)
Exemplo n.º 2
0
    def suggestCmd(self, cmdLine):
        cmds = cmdLine.split(' ')
        cmd = cmds[0]
        try:
            subcmd = cmds[1]
        except IndexError:
            subcmd = None

        param = None
        if(subcmd):
            try:
                param = cmds[2]
            except IndexError:
                pass
    
        if(cmd and (not subcmd)): #only have command
            #try to suggest command
            suggestArr = []
            for c in utils.getCmdList():
                if(c[:len(cmd)] == cmd):
                    suggestArr.append(c)
            
            if(len(suggestArr) == 1): #now we got the only one correct command
                cmd = suggestArr[0]
                cmdLine = cmd + ' '
                if(self.text() == cmdLine):  #need suggest subcommand
                    self.suggestSubcmd(cmd, None)
                else:
                    self.setText(cmdLine)
                return
            elif(len(suggestArr) > 1): #output all possible cmds
                cmd = self._suggest(cmd, suggestArr)
                cmdLine = cmd
                self.setText(cmdLine)
                utils.output(suggestArr)
                return
            
        #now we have command and subcommand
        if(subcmd and (not param)):	
            self.suggestSubcmd(cmd, subcmd)
Exemplo n.º 3
0
def run(subcmd, params):

    cmdList = utils.getCmdList()
    utils.output(desc)
    utils.output(cmdList)