diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-03-21 09:52:34 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-03-21 23:41:57 +0100 |
commit | b9d03aff15778f0e32487bec3a76da2e5024929e (patch) | |
tree | 36b84fadf7ed62f354bfd48586a881ce95532bbb /gbp/scripts/create_remote_repo.py | |
parent | a884ef569828d9d7875427084d7c830f168a655c (diff) |
gbp-create-remote-repo: add --remote-config
This specifies an additional config file section that can be used
to preconfigure different remote locations.
Diffstat (limited to 'gbp/scripts/create_remote_repo.py')
-rw-r--r-- | gbp/scripts/create_remote_repo.py | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/gbp/scripts/create_remote_repo.py b/gbp/scripts/create_remote_repo.py index c26551b8..1e6b3f8a 100644 --- a/gbp/scripts/create_remote_repo.py +++ b/gbp/scripts/create_remote_repo.py @@ -225,10 +225,30 @@ def push_branches(remote, branches): gitPush([remote['url'], '--tags']) -def parse_args(argv): +def parse_args(argv, sections=[]): + """ + Parse the command line arguments and config files. + + @param argv: the command line arguments + @type argv: C{list} of C{str} + @param sections: additional sections to add to the config file parser + besides the command name + @type sections: C{list} of C{str} + """ + + # We simpley handle the template section as an additional config file + # section to parse, this makes e.g. --help work as expected: + for arg in argv: + if arg.startswith('--remote-config='): + sections = ['remote-config %s' % arg.split('=',1)[1]] + break + else: + sections = [] + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', usage='%prog [options] - ' - 'create a remote repository') + 'create a remote repository', + sections=sections) branch_group = GbpOptionGroup(parser, "branch options", "branch layout and tracking options") @@ -257,8 +277,8 @@ def parse_args(argv): help="The name of the remote, default is 'origin'") parser.add_config_file_option(option_name="template-dir", dest="template_dir") - parser.add_config_file_option(option_name="remote-template", - dest="remote_template") + parser.add_config_file_option(option_name="remote-config", + dest="remote_config") (options, args) = parser.parse_args(argv) @@ -270,9 +290,13 @@ def main(argv): changelog = 'debian/changelog' cmd = [] - options, args = parse_args(argv) - gbp.log.setup(options.color, options.verbose) + try: + options, args = parse_args(argv) + except Exception as e: + print >>sys.stderr, "%s" % e + return 1 + gbp.log.setup(options.color, options.verbose) try: repo = DebianGitRepository(os.path.curdir) except GitRepositoryError: |