set inputs for cli

This commit is contained in:
Pablo Martin 2024-06-06 17:39:20 +02:00
parent f1eb555c03
commit afe9e18e0d
4 changed files with 100 additions and 1 deletions

View file

@ -1,12 +1,16 @@
import datetime
import importlib.metadata
import logging
import pathlib
from typing import Union
import click
import pyfiglet
from dotenv import load_dotenv
from xexe.constants import PATHS
from xexe.processes import run_xe_healthcheck
from xexe.inputs_handling import handle_get_rates_inputs
from xexe.processes import run_get_rates, run_xe_healthcheck
logging.basicConfig(
level=logging.DEBUG,
@ -45,3 +49,35 @@ def xe_healthcheck():
logger.info("Running healthcheck against xe.com API.")
run_xe_healthcheck()
logger.info("Healthcheck attempt finished.")
@cli.command()
@click.option(
"--start-date",
type=click.DateTime(),
default=datetime.datetime.today() - datetime.timedelta(days=7),
)
@click.option(
"--end-date",
type=click.DateTime(),
default=datetime.datetime.today(),
)
@click.option(
"--currencies", default=",".join([]), show_default=True, type=click.STRING
)
@click.option("--dry-run", is_flag=True)
@click.option("--output", type=click.STRING)
def get_rates(
start_date: Union[str, datetime.datetime, datetime.date],
end_date: Union[str, datetime.datetime, datetime.date],
currencies: Union[None, str],
dry_run: bool,
output: pathlib.Path,
):
handle_get_rates_inputs()
run_get_rates()
logger.debug(f"Received start_date: {start_date}")
logger.debug(f"Received end_date: {end_date}")
logger.debug(f"Received currencies: {currencies}")
logger.debug(f"dry_run state: {dry_run}")
logger.debug(f"Received output: {output}")