def do_help(self, arg): if arg: Cmd.do_help(self, arg) else: self.say("") headerString = "These are valid commands for Jarvis" formatString = "Format: command ([aliases for command])" self.say(headerString) self.say(formatString, Fore.BLUE) pluginDict = self._plugin_manager.get_plugins() uniquePlugins = {} for key in pluginDict.keys(): plugin = pluginDict[key] if(plugin not in uniquePlugins.keys()): uniquePlugins[plugin.get_name()] = plugin helpOutput = [] for name in sorted(uniquePlugins.keys()): if (name == "help"): continue try: aliasString = ", ".join(uniquePlugins[name].alias()) if (aliasString != ""): pluginOutput = "* " + name + " (" + aliasString + ")" helpOutput.append(pluginOutput) else: helpOutput.append("* " + name) except AttributeError: helpOutput.append("* " + name) Cmd.columnize(self, helpOutput)
def print_menu(arr): global buffered """Main menu printer @param arr is the menu array to print. Fetches input, parses and built-in command keywords, and returns the selected idx. """ if not buffered is None: # buffered input, return if len(buffered) > 0: return buffered.pop(0) else: buffered = None tmp = Cmd() arr = ['\t[%d] %s' % (x + 1, arr[x]) for x in xrange(len(arr))] tmp.columnize(arr, 35) print '\n0) Back' try: choice = raw_input('> ') choice = check_opts(choice) # buffered input if choice > 1: choice = choice.split(' ') buffered = [] for entry in choice[1:]: buffered.append(int(entry)) choice = int(choice[0]) except KeyboardInterrupt: choice = -1 except Exception, e: debug(e) os.system('clear') choice = -1
def print_menu(arr): global buffered """Main menu printer @param arr is the menu array to print. Fetches input, parses and built-in command keywords, and returns the selected idx. """ if not buffered is None: # buffered input, return if len(buffered) > 0: return buffered.pop(0) else: buffered = None tmp = Cmd() arr = ['\t[%d] %s'%(x+1,arr[x]) for x in xrange(len(arr))] tmp.columnize(arr,35) print '\n0) Back' try: choice = raw_input('> ') choice = check_opts(choice) # buffered input if choice > 1: choice = choice.split(' ') buffered = [] for entry in choice[1:]: buffered.append(int(entry)) choice = int(choice[0]) except KeyboardInterrupt: choice = -1 except Exception, e: debug(e) os.system('clear') choice = -1
def do_help(self, plugin: Optional[Plugin]): if plugin is not None: self.jarvis_api.say(plugin.get_doc()) else: self.jarvis_api.say("") headerString = "These are valid commands for Jarvis" formatString = "Format: command ([aliases for command])" self.jarvis_api.say(headerString) self.jarvis_api.say(formatString, Fore.BLUE) pluginDict = self.plugin_manager.get_plugins() uniquePlugins: Dict[str, Plugin] = {} for key in pluginDict.keys(): plugin = pluginDict[key] if (plugin not in uniquePlugins.keys()): uniquePlugins[plugin.get_name()] = plugin helpOutput = [] for name in sorted(uniquePlugins.keys()): if (name == "help"): continue try: aliasString = ", ".join(uniquePlugins[name].alias()) if (aliasString != ""): pluginOutput = "* " + name + " (" + aliasString + ")" helpOutput.append(pluginOutput) else: helpOutput.append("* " + name) except AttributeError: helpOutput.append("* " + name) Cmd.columnize(self, helpOutput, displaywidth=100)
def print_menu(arr): global buffered """Main menu printer @param arr is the menu array to print. Fetches input, parses and built-in command keywords, and returns the selected idx. """ if not buffered is None: # buffered input, return if len(buffered) > 0: return buffered.pop(0) else: buffered = None tmp = Cmd() arr = ['\t[%d] %s' % (x + 1, arr[x]) for x in xrange(len(arr))] tmp.columnize(arr, 35) print '\n0) Back' try: choice = raw_input('> ') if 'info' in choice: Error('\'info\' not implemented yet.') choice = -1 elif 'set' in choice: opts = choice.split(' ') if opts[1] is None or opts[2] is None: return print '[!] Setting \033[33m%s\033[0m -> \033[32m%s\033[0m..' % ( opts[1], opts[2]) config.set(opts[1], opts[2]) choice = -1 elif 'opts' in choice: config.dump() choice = -1 elif 'quit' in choice or 'exit' in choice: # hard quit os._exit(1) elif 'bg' in choice: background() else: # buffered input choice = choice.split(' ') if len(choice) > 1: buffered = [] for entry in choice[1:]: buffered.append(int(entry)) choice = int(choice[0]) except Exception: os.system('clear') choice = -1 return choice
def print_menu(arr): global buffered """Main menu printer @param arr is the menu array to print. Fetches input, parses and built-in command keywords, and returns the selected idx. """ if not buffered is None: # buffered input, return if len(buffered) > 0: return buffered.pop(0) else: buffered = None tmp = Cmd() arr = ['\t[%d] %s'%(x+1,arr[x]) for x in xrange(len(arr))] tmp.columnize(arr,35) print '\n0) Back' try: choice = raw_input('> ') if 'info' in choice: Error('\'info\' not implemented yet.') choice = -1 elif 'set' in choice: opts = choice.split(' ') if opts[1] is None or opts[2] is None: return print '[!] Setting \033[33m%s\033[0m -> \033[32m%s\033[0m..'%(opts[1], opts[2]) config.set(opts[1], opts[2]) choice = -1 elif 'opts' in choice: config.dump() choice = -1 elif 'quit' in choice or 'exit' in choice: # hard quit os._exit(1) elif 'bg' in choice: background() else: # buffered input choice = choice.split(' ') if len(choice) > 1: buffered = [] for entry in choice[1:]: buffered.append(int(entry)) choice = int(choice[0]) except Exception: os.system('clear') choice = -1 return choice
def print_menu(arr): global buffered """ Main menu printer @param arr is the menu array to print. Fetches input, parses and built-in command keywords, and returns the selected idx. """ if not buffered is None: # buffered input, return if len(buffered) > 0: return buffered.pop(0) else: buffered = None tmp = Cmd() arr = [ '\t%s[%s%d%s] %s%s%s' % (color.B_GREEN, color.B_YELLOW, x + 1, color.B_GREEN, color.B_WHITE, arr[x], color.END) for x in xrange(len(arr)) ] tmp.columnize(arr, 100) print '\n' + color.B_YELLOW + '0' + color.B_GREEN + ')' + color.B_WHITE + ' Back' + color.END try: choice = raw_input(color.B_WHITE + '> ' + color.END) choice = check_opts(choice) # buffered input if choice > 1: choice = choice.split(' ') buffered = [] for entry in choice[1:]: buffered.append(int(entry)) choice = int(choice[0]) except KeyboardInterrupt: choice = -1 except Exception, e: debug(e) os.system('clear') choice = -1
def print_menu(arr): global buffered """ Main menu printer @param arr is the menu array to print. Fetches input, parses and built-in command keywords, and returns the selected idx. """ if not buffered is None: # buffered input, return if len(buffered) > 0: return buffered.pop(0) else: buffered = None tmp = Cmd() arr = ['\t%s[%s%d%s] %s%s%s' % (color.B_GREEN, color.B_YELLOW, x + 1, color.B_GREEN, color.B_WHITE, arr[x], color.END) for x in xrange(len(arr))] tmp.columnize(arr, 100) print '\n' + color.B_YELLOW + '0' + color.B_GREEN + ')' + color.B_WHITE + ' Back' + color.END try: choice = raw_input(color.B_WHITE + '> ' + color.END) choice = check_opts(choice) # buffered input if choice > 1: choice = choice.split(' ') buffered = [] for entry in choice[1:]: buffered.append(int(entry)) choice = int(choice[0]) except KeyboardInterrupt: choice = -1 except Exception, e: debug(e) os.system('clear') choice = -1