def main():
    """
    Setup the parser and call the command function
    """
    parser = argparse.ArgumentParser(description='Longclaw CLI')
    subparsers = parser.add_subparsers()
    start = subparsers.add_parser('start', help='Create a Wagtail+Longclaw project')
    start.add_argument('project_name', help='Name of the project')
    start.set_defaults(func=create_project)

    build = subparsers.add_parser('build', help='Build the front-end assets for Longclaw')
    build.set_defaults(func=build_assets)

    args = parser.parse_args()

    # Python 3 lost the default behaviour to fall back to printing
    # help if a subparser is not selected.
    # See: https://bugs.python.org/issue16308
    # So we must explicitly catch the error thrown on py3 if
    # no commands given to longclaw
    try:
        args.func(args)
    except AttributeError:
        parser.print_help()
        sys.exit(0)
def main ( ) : parser = argparse . ArgumentParser ( description = 'Longclaw CLI' ) subparsers = parser . add_subparsers ( ) start = subparsers . add_parser ( 'start' , help = 'Create a Wagtail+Longclaw project' ) start . add_argument ( 'project_name' , help = 'Name of the project' ) start . set_defaults ( func = create_project ) build = subparsers . add_parser ( 'build' , help = 'Build the front-end assets for Longclaw' ) build . set_defaults ( func = build_assets ) args = parser . parse_args ( ) try : args . func ( args ) except AttributeError : parser . print_help ( ) sys . exit ( 0 )
Setup the parser and call the command function