1
0

Basic CLI

This commit is contained in:
Jon Michael Aanes 2024-07-22 14:53:48 +02:00
parent ccdaa8fd15
commit f5b69badd4

View File

@ -1,10 +1,12 @@
import datetime import datetime
import logging import logging
import logging.handlers import logging.handlers
import argparse
import time import time
from decimal import Decimal from decimal import Decimal
import fin_defs import fin_defs
import fin_depo
from . import PATH_LOG_FILE, AutoSellConfig, config, run_auto_sell, log_results from . import PATH_LOG_FILE, AutoSellConfig, config, run_auto_sell, log_results
from . import logger as module_logger from . import logger as module_logger
@ -13,6 +15,7 @@ logger = logging.getLogger(__name__)
def setup_logging(): def setup_logging():
"""Enables logging for the terminal and to a log file."""
PATH_LOG_FILE.parent.mkdir(parents=True, exist_ok=True) PATH_LOG_FILE.parent.mkdir(parents=True, exist_ok=True)
file_handler = logging.handlers.WatchedFileHandler(filename=PATH_LOG_FILE) file_handler = logging.handlers.WatchedFileHandler(filename=PATH_LOG_FILE)
file_handler.setFormatter( file_handler.setFormatter(
@ -27,9 +30,20 @@ def setup_logging():
logger.setLevel('INFO') logger.setLevel('INFO')
module_logger.setLevel('INFO') module_logger.setLevel('INFO')
CLI_DESCRIPTION = """
Sells financial assets from an online account.
""".strip()
def parse_args():
parser = argparse.ArgumentParser('crypto_seller', description = CLI_DESCRIPTION)
return parser.parse_args()
def main(): def main():
"""Initializes the program."""
setup_logging() setup_logging()
args = parse_args()
logger.info('Initializing crypto_seller') logger.info('Initializing crypto_seller')
seller_backend = fin_depo.defi_kucoin.KucoinDepoFetcher( seller_backend = fin_depo.defi_kucoin.KucoinDepoFetcher(