Skip to content

Commit

Permalink
Move to main
Browse files Browse the repository at this point in the history
  • Loading branch information
demonno committed Apr 2, 2022
1 parent c0d4693 commit 5eb32ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ requests-mock = "^1.8"
coverage = "^6.3.2"

[tool.poetry.scripts]
ynab-import = "ynab_import.main:main"
ynab-import = "ynab_import.__main__:app"

[tool.isort]
profile = "black"
Expand Down
24 changes: 24 additions & 0 deletions ynab_import/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Invoke as `ynab-import' or `python -m ynab_import'.
"""
import typer

from ynab_import.cli import create_reader, create_writer
from ynab_import.common.settings import ReaderKind, WriterKind
from ynab_import.core import import_transactions

app = typer.Typer(add_completion=False)


@app.command()
def cli(
reader: ReaderKind = ReaderKind.swedbank_csv,
writer: WriterKind = WriterKind.ynab_api,
):
reader = create_reader(reader)
writer = create_writer(writer)
count = import_transactions(read=reader, write=writer)
message = f"Transaction(s) imported: N {count} " + typer.style("good", fg=typer.colors.GREEN, bold=True)
typer.echo(message)


app()
20 changes: 0 additions & 20 deletions ynab_import/main.py → ynab_import/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import typer

from ynab_import.common.settings import ReaderKind, WriterKind, settings
from ynab_import.core import import_transactions
from ynab_import.core.interactions import IReadRepository, IWriteRepository
from ynab_import.infra.http import RequestsClient
from ynab_import.infra.ynab import YnabAPIBasedRepository
Expand Down Expand Up @@ -31,20 +28,3 @@ def create_writer(writer: WriterKind) -> IWriteRepository:
raise NotImplementedError(f"{writer} writer is not implemented.")


app = typer.Typer(add_completion=False)


@app.command()
def cli(
reader: ReaderKind = ReaderKind.swedbank_csv,
writer: WriterKind = WriterKind.ynab_api,
):
reader = create_reader(reader)
writer = create_writer(writer)
count = import_transactions(read=reader, write=writer)
message = f"Transaction(s) imported: N {count} " + typer.style("good", fg=typer.colors.GREEN, bold=True)
typer.echo(message)


def main():
app()

0 comments on commit 5eb32ff

Please sign in to comment.