示例#1
0
def _build_parser():
    cmdname = _find_command()

    if cmdname is not None and not commands.has_command(cmdname):
        raise CommandLineError('unknown command: %s (see --help)' %
                               (cmdname, ))

    config = _make_config(cmdname)

    cmd = commands.get_command(cmdname) if cmdname is not None else None

    # Epilog newlines/formatting is squashed by option parser. Something else
    # to fix.
    if cmdname is None:
        epilog = (["Available commands: "] +
                  [cmd.name for cmd in sorted(commands.all_commands())])
        usage = '%prog <command> [args] [options]'
    else:
        epilog = ['%s: %s' % (cmdname, cmd.__doc__)]
        usage = '%%prog %s [args] [options]' % (cmdname, )

    parser = optparse.OptionParser(usage=usage, epilog=' '.join(epilog))

    for opt in config.options().itervalues():
        opt.populate_optparser(parser)

    return parser
示例#2
0
def _build_parser():
    cmdname = _find_command()

    if cmdname is not None and not commands.has_command(cmdname):
        raise CommandLineError('unknown command: %s (see --help)' % (cmdname,))

    config = _make_config(cmdname)

    cmd = commands.get_command(cmdname) if cmdname is not None else None

    # Epilog newlines/formatting is squashed by option parser. Something else
    # to fix.
    if cmdname is None:
        epilog = ([ "Available commands: " ] +
                  [ cmd.name for cmd in sorted(commands.all_commands()) ])
        usage = '%prog <command> [args] [options]'
    else:
        epilog = ['%s: %s' % (cmdname, cmd.__doc__)]
        usage = '%%prog %s [args] [options]' % (cmdname,)

    parser = optparse.OptionParser(usage=usage,
                                   epilog=' '.join(epilog))

    for opt in config.options().itervalues():
        opt.populate_optparser(parser)

    return parser
示例#3
0
def _make_config(cmdname):
    """
    @param cmdname: Command name of None (for global options).
    @return Configuration instance.
    """
    if cmdname is not None:
        cmd = commands.get_command(cmdname)
        opts = cmd.options
    else:
        opts = options.GlobalOptions()

    return opts
示例#4
0
def _make_config(cmdname):
    """
    @param cmdname: Command name of None (for global options).
    @return Configuration instance.
    """
    if cmdname is not None:
        cmd = commands.get_command(cmdname)
        opts = cmd.options
    else:
        opts = options.GlobalOptions()

    return opts
示例#5
0
def _make_config(cmdname):
    """
    @param cmdname: Command name of None (for global options).
    @return Configuration instance.
    """
    if cmdname is not None:
        cmd = commands.get_command(cmdname)
        opts = cmd.options
    else:
        opts = options.GlobalOptions()

    if cmdname and cmdname in ('list-manifest', 'list-files', 'persist',
                               'materialize', 'get-blocks', 'show-manifest',
                               'common-blocks', 'list-blocks', 'list-orphans'):
        opts = opts.merge(options.EncryptionOptions())
        opts = opts.merge(options.S3Options())

    if cmdname and cmdname in ('persist'):
        opts = opts.merge(options.PersistOptions())

    return opts
示例#6
0
def _make_config(cmdname):
    """
    @param cmdname: Command name of None (for global options).
    @return Configuration instance.
    """
    if cmdname is not None:
        cmd = commands.get_command(cmdname)
        opts = cmd.options
    else:
        opts = options.GlobalOptions()

    if cmdname and cmdname in ('list-manifest',
                               'list-files',
                               'persist', 'materialize',
                               'get-blocks', 'show-manifest',
                               'common-blocks', 'list-blocks',
                               'list-orphans'):
        opts = opts.merge(options.EncryptionOptions())
        opts = opts.merge(options.S3Options())

    if cmdname and cmdname in ('persist'):
        opts = opts.merge(options.PersistOptions())

    return opts