diff --git a/pisi-cli b/pisi-cli index a529588b..b477dc5f 100755 --- a/pisi-cli +++ b/pisi-cli @@ -25,23 +25,6 @@ Use \"%prog help \" for help on a specific subcommand. PISI Package Manager """ -# def commonopts(parser): -# parser.add_option("-D", "--destdir", action="store") -# parser.add_option("-u", "--username", action="store") -# parser.add_option("-p", "--password", action="store") -# parser.add_option("-P", action="store_true", dest="getpass", default=False, -# help="Get password from the command line") -# parser.add_option("-v", "--verbose", action="store_true", -# dest="verbose", default=False, -# help="detailed output") -# parser.add_option("-d", "--debug", action="store_true", -# default=True, help="show debugging information") -# parser.add_option("-n", "--dry-run", action="store_true", default=False, -# help = "do not perform any action, just show what\ -# would be done") -# return parser - - class ParserError: def __init__(self, msg): self.msg = msg @@ -54,52 +37,65 @@ class Parser(OptionParser): def error(self, msg): raise ParserError(msg) +# eheh, burada ne yaptigim anlasilamamis galiba +# sunlari yazin: +# pisi-cli --test remove x +# pisi-cli --test build x +# diger turlu olmaz bu. dikkat. per command optionlar +# svn log'unda anlatmistim. simdi bir daha yazmam gerekti bazi +# seyleri bastan calistirabilmek icin. bir ise yaramasa yapmazdim. + class PisiCLI(object): commands = ["help", "build", "info", "install", "remove", "index", "updatedb"] + def commonopts(self): + p = self.parser + p.add_option("-D", "--destdir", action="store") + p.add_option("-u", "--username", action="store") + p.add_option("-p", "--password", action="store") + p.add_option("-P", action="store_true", dest="getpass", default=False, + help="Get password from the command line") + p.add_option("-v", "--verbose", action="store_true", + dest="verbose", default=False, + help="detailed output") + p.add_option("-d", "--debug", action="store_true", + default=True, help="show debugging information") + p.add_option("-n", "--dry-run", action="store_true", default=False, + help = "do not perform any action, just show what\ + would be done") + + def __init__(self): # first construct a parser for common options # this is really dummy - parser = Parser(usage=usage, version="%prog " + pisi.__version__) -# parser.allow_interspersed_args = False -# parser = commonopts(parser) - parser.add_option("-D", "--destdir", action="store") - parser.add_option("-u", "--username", action="store") - parser.add_option("-p", "--password", action="store") - parser.add_option("-P", action="store_true", dest="getpass", default=False, - help="Get password from the command line") - parser.add_option("-v", "--verbose", action="store_true", - dest="verbose", default=False, - help="detailed output") - parser.add_option("-d", "--debug", action="store_true", - default=True, help="show debugging information") - parser.add_option("-n", "--dry-run", action="store_true", default=False, - help = "do not perform any action, just show what\ - would be done") + self.parser = Parser(usage=usage, version="%prog " + pisi.__version__) + #self.parser.allow_interspersed_args = False + self.commonopts() self.command = "" try: - (options, args) = parser.parse_args() -# if len(parser.rargs)==0: -# self.die() + (options, args) = self.parser.parse_args() + #if len(parser.rargs)==0: + # self.die() self.command = args[0] except ParserError: # fully expected :) let's see if we got an argument - if len(parser.rargs)==0: + if len(self.parser.rargs)==0: self.die() - #print 'rargs', parser.rargs, 'vals', parser.values - self.command = parser.rargs[0] + self.command = self.parser.rargs[0] -# # now for the real parser -# parser = OptionParser(usage=usage, version="%prog " + pisi.__version__) -# parser.allow_interspersed_args = False -# self.parser = commonopts(parser) -# self.add_subcommand_opts() -# (self.options, args) = self.parser.parse_args() + #print '*', self.command + + # now for the real parser THIS IS ABSOLUTELY NECESSARY + self.parser = OptionParser(usage=usage, + version="%prog " + pisi.__version__) + #self.parser.allow_interspersed_args = False + self.commonopts() + self.add_subcommand_opts() + (self.options, args) = self.parser.parse_args() self.args = args[1:] - self.options = options self.authInfo = None self.checkAuthInfo()