* get rid of common
This commit is contained in:
+31
-1
@@ -49,7 +49,7 @@ class Command(object):
|
||||
self.parser = OptionParser(usage=getattr(self, "__doc__"),
|
||||
version="%prog " + pisi.__version__)
|
||||
self.options()
|
||||
self.parser = commonopts(self.parser)
|
||||
self.commonopts()
|
||||
(self.options, self.args) = self.parser.parse_args()
|
||||
self.args.pop(0) # exclude command arg
|
||||
|
||||
@@ -61,6 +61,26 @@ class Command(object):
|
||||
|
||||
self.check_auth_info()
|
||||
|
||||
def commonopts():
|
||||
'''common options'''
|
||||
p = self.parser
|
||||
p.add_option("-D", "--destdir", action="store")
|
||||
p.add_option("", "--yes-all", action="store_true",
|
||||
default=False, help = "assume yes in all yes/no queries")
|
||||
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")
|
||||
return p
|
||||
|
||||
def options(self):
|
||||
"""This is a fall back function. If the implementer module provides an
|
||||
options function it will be called"""
|
||||
@@ -757,4 +777,14 @@ commands = {"help": Help,
|
||||
"list-repo": ListRepo
|
||||
}
|
||||
|
||||
usage_text1 = """%prog <command> [options] [arguments]
|
||||
|
||||
where <command> is one of:
|
||||
|
||||
"""
|
||||
|
||||
usage_text2 = """
|
||||
Use \"%prog help <command>\" for help on a specific command.
|
||||
"""
|
||||
|
||||
usage_text = (usage_text1 + commands_string() + usage_text2)
|
||||
|
||||
Reference in New Issue
Block a user