#!/usr/bin/env python

import os
import logging
import argparse
import sys

import cdx_toolkit

print('This command is deprecated in favor of cdxt', file=sys.stderr)

loglevel = os.getenv('LOGLEVEL') or 'WARNING'
logging.basicConfig(level=loglevel)

ARGS = argparse.ArgumentParser(description='cdx_toolkit size command line tool')
ARGS.add_argument('--cc', action='store_true')
ARGS.add_argument('--ia', action='store_true')
ARGS.add_argument('url')

args = ARGS.parse_args()

if not (args.cc or args.ia):
    raise ValueError('must specify one of --cc or --ia')

if args.cc:
    cdx = cdx_toolkit.CDXFetcher(source='cc')
    print('cc size estimate', cdx.get_size_estimate(args.url))

if args.ia:
    cdx = cdx_toolkit.CDXFetcher(source='ia')
    print('ia size estimate', cdx.get_size_estimate(args.url))
