From e405cc6a049f256fc4e8588f6bbb2e8de99ddc36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Wed, 13 Jul 2005 00:37:31 +0000 Subject: [PATCH] =?UTF-8?q?bir=20iki=20hata=20d=C3=BCzeltildi.=20-=20help?= =?UTF-8?q?=20d=C3=BCzg=C3=BCn=20=C3=A7al=C4=B1=C5=9Fm=C4=B1yordu...=20-?= =?UTF-8?q?=20usage=20optparse'da=20kullan=C4=B1lan=20bir=20de=C4=9Fi?= =?UTF-8?q?=C5=9Fken,=20yerine=20usage=5Ftext=20kulland=C4=B1m=20-=20updat?= =?UTF-8?q?edb=20komutu=20=C3=A7al=C4=B1=C5=9Fs=C4=B1n.=20-=20ParseError?= =?UTF-8?q?=20yakalanmak=20i=C3=A7in=20bir=20exception=20olsun.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/cli/pisicli.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pisi/cli/pisicli.py b/pisi/cli/pisicli.py index 91050bcc..93c7bc89 100644 --- a/pisi/cli/pisicli.py +++ b/pisi/cli/pisicli.py @@ -8,7 +8,7 @@ from pisi.config import config # globals -usage = """%prog [options] [arguments] +usage_text = """%prog [options] [arguments] where is one of: @@ -68,7 +68,7 @@ class Command(object): """generic help string for any command""" def __init__(self): # now for the real parser THIS IS ABSOLUTELY NECESSARY - self.parser = OptionParser(usage=usage, + self.parser = OptionParser(usage=usage_text, version="%prog " + pisi.__version__) #self.parser.allow_interspersed_args = False self.options() @@ -109,12 +109,12 @@ class Help(Command): def __init__(self): super(Help, self).__init__() - def run(self, args=None): - if not args: - print usage + def run(self): + if not self.args: + print usage_text return - for arg in args: + for arg in self.args: obj = cmdObject(arg, True) obj.help() @@ -205,7 +205,7 @@ class Index(Command): indexhelper.index() else: print 'Indexing only a single directory supported' - self.die() + return class UpdateDB(Command): """updatedb: update source and package databases""" @@ -217,27 +217,27 @@ class UpdateDB(Command): self.help() return + from pisi.cli import indexhelper indexfile = self.args[0] indexhelper.updatedb(indexfile) ######## end commands ######### -class ParserError: - def __init__(self, msg): - self.msg = msg +class ParserError(Exception): + pass class Parser(OptionParser): - def __init__(self, usage, version): - OptionParser.__init__(self, usage=usage, version=version) + def __init__(self, version): + OptionParser.__init__(self, usage=usage_text, version=version) def error(self, msg): - raise ParserError(msg) + raise ParserError, msg class PisiCLI(object): def __init__(self): # first construct a parser for common options # this is really dummy - self.parser = Parser(usage=usage, version="%prog " + pisi.__version__) + self.parser = Parser(version="%prog " + pisi.__version__) #self.parser.allow_interspersed_args = False self.parser = commonopts(self.parser) @@ -262,7 +262,7 @@ class PisiCLI(object): self.die() def die(self): - print usage + print usage_text sys.exit(1) def runCommand(self):