def subCommandUsage(self, subCommandName, errNo=1): if not self._subCommands.has_key(subCommandName): print "%s %s: no such subcommand: %s" % \ (self.mainHandler.name, self.commands[0], subCommandName) sys.exit(1) thisCommand = self._subCommands[subCommandName]() thisCommand.setMainHandler(self.mainHandler) params, _ = thisCommand.prepare() usage = '%s %s %s %s' % (self.mainHandler.name, '/'.join(self.commands), subCommandName, thisCommand.paramHelp) kwargs = self.mainHandler._getParserFlags(thisCommand) kwargs['defaultGroup'] = None parser = options._getParser(params, {}, usage=usage, **kwargs) parser.print_help() if log.getVerbosity() > log.INFO: print '(Use --verbose to get a full option listing)' return errNo
def getParserByClass(self, commandClass, commandName=None): params, cfgMap = commandClass.prepare() usage = self._getUsageByClass(commandClass, commandName=commandName) kwargs = self._getParserFlags(commandClass) return options._getParser(params, {}, usage=usage, **kwargs)