#!/bin/sh
require('dotenv').config();
global.fetch = require('node-fetch')

const {program} = require('commander');
const calculate = require('./functions/calculate');

program
    .version('0.0.1')
    .argument('<file>', 'transactions to analyse')
    .option('-t, --tokens <tokens>', 'token/s to evaluate')
    .option('-d, --date <date>', 'date to start from')
    .parse();

const options = program.opts();
const [file] = program.args;

if (!file) {
    console.log('No transactions file provided');
    process.exit(1);
}

if (!options.tokens) {
    console.log('No token specified. So will analyse all tokens');
}

if (!options.date) {
    console.log('No date specified. So will analyse from the beginning');
}

calculate(file, options.tokens, options.date);