from ConfigParser import SafeConfigParser, NoSectionError
from copy import copy
import os.path
+import sys
try:
from gbp.version import gbp_version
except ImportError:
else:
self.config['filter'] = []
- def __init__(self, command, prefix='', usage=None, sections=[]):
+ def __init__(self, command=None, prefix='', usage=None, sections=[]):
"""
@param command: the command to build the config parser for
@type command: C{str}
to parse
@type sections: C{list} of C{str}
"""
+ if not command:
+ command = os.path.basename(sys.argv[0])
+ if command == 'gbp':
+ command += " " + os.path.basename(sys.argv[1])
self.command = command
self.sections = sections
self.prefix = prefix
self.config_files = self.get_config_files()
self._parse_config_files()
OptionParser.__init__(self, option_class=GbpOption,
+ prog=command,
usage=usage, version='%s %s' % (self.command,
gbp_version))
args.append(arg)
try:
- parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix=prefix)
+ parser = GbpOptionParserDebian(prefix=prefix)
except ConfigParser.ParsingError as err:
gbp.log.err(err)
return None, None, None
def parse_args (argv):
try:
- parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
- usage='%prog [options] repository - clone a remote repository')
+ parser = GbpOptionParser(usage='%prog [options] repository - clone a remote repository')
except ConfigParser.ParsingError as err:
gbp.log.err(err)
return None, None
else:
sections = []
- parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
- usage='%prog [options] - '
+ parser = GbpOptionParserDebian(usage='%prog [options] - '
'create a remote repository',
sections=sections)
branch_group = GbpOptionGroup(parser,
branch = None
try:
- parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
- usage='%prog [options] paths')
+ parser = GbpOptionParserDebian(usage='%prog [options] paths')
except ConfigParser.ParsingError as err:
gbp.log.err(err)
return 1
def parse_args(argv):
try:
- parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
- usage='%prog [options] /path/to/package.dsc')
+ parser = GbpOptionParserDebian(usage='%prog [options] /path/to/package.dsc')
except ConfigParser.ParsingError as err:
gbp.log.err(err)
return None, None
def parse_args(argv):
try:
- parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
- usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan')
+ parser = GbpOptionParserDebian(usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan')
except ConfigParser.ParsingError as err:
gbp.log.err(err)
return None, None
def parse_args(argv):
try:
- parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
- usage="%prog [options] action - maintain patches on a patch queue branch\n"
+ parser = GbpOptionParserDebian(usage="%prog [options] action - maintain patches on a patch queue branch\n"
"Actions:\n"
" export export the patch queue associated to the current branch\n"
" into a quilt patch series in debian/patches/ and update the\n"
def parse_args(argv):
try:
- parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
- usage='%prog [options] - safely update a repository from remote')
+ parser = GbpOptionParser(usage='%prog [options] - safely update a repository from remote')
except ConfigParser.ParsingError as err:
gbp.log.err(err)
return None, None