def parse_options():
    """Define sub-commands and command line options."""

    server, username, password, auto_update_soa = False, False, False, False

    prs = argparse.ArgumentParser(description='usage')
    prs.add_argument('-v', '--version', action='version',
                     version=__version__)
    if os.environ.get('HOME'):
        config_file = os.environ.get('HOME') + '/.tdclirc'
        if os.path.isfile(config_file):
            (server, username,
             password, auto_update_soa) = check_config(config_file)

    conn = dict(server=server, username=username,
                password=password, auto_update_soa=auto_update_soa)

    subprs = prs.add_subparsers(help='commands')

    # Convert and print JSON
    parse_show(subprs)

    # Retrieve records
    parse_get(subprs, conn)

    # Create record
    parse_create(subprs, conn)

    # Create bulk_records
    parse_bulk_create(subprs, conn)

    # Delete record
    parse_delete(subprs, conn)

    # Delete bulk_records
    parse_bulk_delete(subprs, conn)

    # Update a record
    parse_update(subprs, conn)

    # Update SOA serial
    parse_update_soa(subprs, conn)

    # Create zone
    parse_create_zone(subprs, conn)

    # Delete zone
    parse_delete_zone(subprs, conn)

    # Retrieve template
    parse_get_tmpl(subprs, conn)

    # Delete template
    parse_delete_tmpl(subprs, conn)

    args = prs.parse_args()
    return args
def parse_options ( ) : server , username , password , auto_update_soa = False , False , False , False prs = argparse . ArgumentParser ( description = 'usage' ) prs . add_argument ( '-v' , '--version' , action = 'version' , version = __version__ ) if os . environ . get ( 'HOME' ) : config_file = os . environ . get ( 'HOME' ) + '/.tdclirc' if os . path . isfile ( config_file ) : ( server , username , password , auto_update_soa ) = check_config ( config_file ) conn = dict ( server = server , username = username , password = password , auto_update_soa = auto_update_soa ) subprs = prs . add_subparsers ( help = 'commands' ) parse_show ( subprs ) parse_get ( subprs , conn ) parse_create ( subprs , conn ) parse_bulk_create ( subprs , conn ) parse_delete ( subprs , conn ) parse_bulk_delete ( subprs , conn ) parse_update ( subprs , conn ) parse_update_soa ( subprs , conn ) parse_create_zone ( subprs , conn ) parse_delete_zone ( subprs , conn ) parse_get_tmpl ( subprs , conn ) parse_delete_tmpl ( subprs , conn ) args = prs . parse_args ( ) return args
Define sub-commands and command line options.