#!/usr/bin/env python3

import readline
import code
import numpy as np
from sys import argv, exit, stderr

from loguru import logger
logger.remove()
logger.add(stderr, level='INFO')

from grapple.utils import * 

p = ArgumentParser()
p.add_args(
    ('--verbose', ArgumentParser.STORE_TRUE),
    ('--python', ArgumentParser.STORE_TRUE),
    ('files', ArgumentParser.MANY)
)
args = p.parse_args()

data = {}
for fpath in args.files:
    data[fpath] = np.load(fpath)
    if args.verbose:
        logger.info(fpath)

if len(data) == 1:
    d = list(data.values())[0]
else:
    d = data

if args.python:
    vars = globals().copy()
    vars.update(locals())
    shell = code.InteractiveConsole(vars)
    shell.interact()
else:
    try:
        from IPython import embed
        embed()
    except ImportError as e:
        logger.error('IPython not found, try passing --python for bare python shell')
exit(1)
