def get_parsed_args()

in templates/custom-resources/lex-manager.py [0:0]


def get_parsed_args():
    """ Parse arguments passed when running as a shell script
    """
    parser = argparse.ArgumentParser(
        description='Lex bot manager. Import, export or delete a Lex bot.'
            ' Used to import/export/delete Lex bots and associated resources'
            ' (i.e. intents, slot types).'
    )
    format_group = parser.add_mutually_exclusive_group()
    format_group.add_argument('-i', '--import',
        nargs='?',
        default=argparse.SUPPRESS,
        const=BOT_DEFINITION_FILENAME,
        metavar='file',
        help='Import bot definition from file into account. Defaults to: {}'
            .format(BOT_DEFINITION_FILENAME),
    )
    format_group.add_argument('-e', '--export',
        nargs='?',
        default=argparse.SUPPRESS,
        metavar='botname',
        help='Export bot definition as JSON to stdout'
            ' Defaults to reading the botname from the definition file: {}'
            .format(BOT_DEFINITION_FILENAME),
    )
    format_group.add_argument('-d', '--delete',
        nargs=1,
        default=argparse.SUPPRESS,
        metavar='botname',
        help='Deletes the bot passed as argument and its associated resources.'
    )

    args = parser.parse_args()
    if not bool(vars(args)):
        parser.print_help()
        sys.exit(1)

    return args