def main(manual_args=None):
    """Foremast, your ship's support."""
    parser = argparse.ArgumentParser(description=main.__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.set_defaults(func=parser.print_help)
    add_debug(parser)
    parser.add_argument(
        '-s',
        '--short-log',
        action='store_const',
        const=SHORT_LOGGING_FORMAT,
        default=LOGGING_FORMAT,
        help='Truncated logging format')
    parser.add_argument('-v', '--version', action='store_true', help=print_version.__doc__)

    subparsers = parser.add_subparsers(title='Commands', description='Available activies')

    add_infra(subparsers)
    add_pipeline(subparsers)
    add_rebuild(subparsers)
    add_autoscaling(subparsers)
    add_validate(subparsers)

    CliArgs = collections.namedtuple('CliArgs', ['parsed', 'extra'])

    parsed, extra = parser.parse_known_args(args=manual_args)
    args = CliArgs(parsed, extra)

    logging.basicConfig(format=args.parsed.short_log)

    package, *_ = __package__.split('.')
    logging.getLogger(package).setLevel(args.parsed.debug)

    LOG.debug('Arguments: %s', args)

    if args.parsed.version:
        args.parsed.func = print_version

    try:
        args.parsed.func(args)
    except (AttributeError, TypeError):
        args.parsed.func()
def main ( manual_args = None ) : parser = argparse . ArgumentParser ( description = main . __doc__ , formatter_class = argparse . ArgumentDefaultsHelpFormatter ) parser . set_defaults ( func = parser . print_help ) add_debug ( parser ) parser . add_argument ( '-s' , '--short-log' , action = 'store_const' , const = SHORT_LOGGING_FORMAT , default = LOGGING_FORMAT , help = 'Truncated logging format' ) parser . add_argument ( '-v' , '--version' , action = 'store_true' , help = print_version . __doc__ ) subparsers = parser . add_subparsers ( title = 'Commands' , description = 'Available activies' ) add_infra ( subparsers ) add_pipeline ( subparsers ) add_rebuild ( subparsers ) add_autoscaling ( subparsers ) add_validate ( subparsers ) CliArgs = collections . namedtuple ( 'CliArgs' , [ 'parsed' , 'extra' ] ) parsed , extra = parser . parse_known_args ( args = manual_args ) args = CliArgs ( parsed , extra ) logging . basicConfig ( format = args . parsed . short_log ) package , * _ = __package__ . split ( '.' ) logging . getLogger ( package ) . setLevel ( args . parsed . debug ) LOG . debug ( 'Arguments: %s' , args ) if args . parsed . version : args . parsed . func = print_version try : args . parsed . func ( args ) except ( AttributeError , TypeError ) : args . parsed . func ( )
Foremast, your ship's support.