def parseArgsAndRun(self, args): """Parse the given argument list and call the run method.""" takes_arguments = list(self.arguments) takes_options = list(self.options) argdict = {} while len(args) > 0: arg = args.pop(0) # If it's an option. if len(arg) > 0 and arg[0] == '-': # Handle -h, --help specially, so that you can use -h after all # commands to get help. if arg in ['-h', '--help']: from siptracklib.help import show_topic_help show_topic_help(self.name) return parse_option(arg, args, takes_options, argdict) # And if it's an argument. else: parse_argument(arg, args, takes_arguments, argdict) if len(takes_arguments) > 1: raise SiptrackCommandError('missing required arguments') if len(takes_arguments) == 1 and not takes_arguments[0].isOptional(): raise SiptrackCommandError('missing required arguments') if self.connected: self.object_store = self.cm.connect() self.transport = self.object_store.transport self.view_tree = self.object_store.view_tree self.run(**argdict) self.cm.disconnect()
def parseArgsAndRun(self, args): """Parse the given argument list and call the run method.""" takes_arguments = list(self.arguments) takes_options = list(self.options) argdict = {} while len(args) > 0: arg = args.pop(0) # If it's an option. if len(arg) > 0 and arg[0] == "-": # Handle -h, --help specially, so that you can use -h after all # commands to get help. if arg in ["-h", "--help"]: from siptracklib.help import show_topic_help show_topic_help(self.name) return parse_option(arg, args, takes_options, argdict) # And if it's an argument. else: parse_argument(arg, args, takes_arguments, argdict) if len(takes_arguments) > 1: raise SiptrackCommandError("missing required arguments") if len(takes_arguments) == 1 and not takes_arguments[0].isOptional(): raise SiptrackCommandError("missing required arguments") if self.connected: self.object_store = self.cm.connect() self.transport = self.object_store.transport self.view_tree = self.object_store.view_tree self.run(**argdict) self.cm.disconnect()
def run(self, topic=None): from siptracklib import help if not topic: help.show_global_help() else: help.show_topic_help(topic) return 0
def run(self, topic = None): from siptracklib import help if not topic: help.show_global_help() else: help.show_topic_help(topic) return 0