diff --git a/ofx_processor/main.py b/ofx_processor/main.py index ffb8584..1b04a85 100644 --- a/ofx_processor/main.py +++ b/ofx_processor/main.py @@ -2,6 +2,7 @@ import click import ofx_processor.bpvf_processor.main as bpvf import ofx_processor.revolut_processor.main as revolut +from ofx_processor.utils import ynab CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) @@ -14,6 +15,7 @@ def cli(): cli.add_command(bpvf.cli, name="bpvf") cli.add_command(revolut.cli, name="revolut") +cli.add_command(ynab.config, name="config") if __name__ == "__main__": cli() diff --git a/ofx_processor/utils/ynab.py b/ofx_processor/utils/ynab.py index 4a6f9f2..76e30ad 100644 --- a/ofx_processor/utils/ynab.py +++ b/ofx_processor/utils/ynab.py @@ -21,12 +21,31 @@ def get_default_config(): return default_config +def get_config_file_name(): + config_file = os.path.join(DEFAULT_CONFIG_DIR, DEFAULT_CONFIG_FILENAME) + return config_file + + +@click.group() +def config(): + pass + + +@click.command() +def edit_config(): + config_file = get_config_file_name() + click.edit(filename=config_file) + + +config.add_command(edit_config, "edit") + + def push_transactions(transactions, account): if not transactions: click.secho("No transaction, nothing to do.", fg="yellow") return config = configparser.ConfigParser() - config_file = os.path.join(DEFAULT_CONFIG_DIR, DEFAULT_CONFIG_FILENAME) + config_file = get_config_file_name() if not os.path.isfile(config_file): os.makedirs(DEFAULT_CONFIG_DIR, exist_ok=True) config = get_default_config() @@ -56,7 +75,11 @@ def push_transactions(transactions, account): matched_id = transaction["matched_transaction_id"] if not matched_id or matched_id not in created: created.add(transaction["id"]) - click.secho(f"{len(created)} transactions created in YNAB.", fg="green", bold=True) + + if created: + click.secho( + f"{len(created)} transactions created in YNAB.", fg="green", bold=True + ) duplicates = data["duplicate_import_ids"] if duplicates: