diff --git a/.gitignore b/.gitignore index f8c7c9e..27e243e 100644 --- a/.gitignore +++ b/.gitignore @@ -159,4 +159,6 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ .fleet/ -.vscode/ \ No newline at end of file +.vscode/ + +*.DS_Store diff --git a/odd_cli/apps/metadata.py b/odd_cli/apps/metadata.py index 03b8f78..b1bee8e 100644 --- a/odd_cli/apps/metadata.py +++ b/odd_cli/apps/metadata.py @@ -8,13 +8,7 @@ from odd_cli.logger import logger from odd_cli.reader.reader import read -app = typer.Typer( - short_help="Collect and ingest metadata for local files from folder", - pretty_exceptions_show_locals=False, -) - -@app.callback() def collect( folder: Path = typer.Argument(..., exists=True, resolve_path=True), platform_host: str = typer.Option(..., "--host", "-h", envvar="ODD_PLATFORM_HOST"), @@ -22,7 +16,8 @@ def collect( ..., "--token", "-t", envvar="ODD_PLATFORM_TOKEN" ), ): - "Collect and ingest metadata for local files from folder" + """Collect and ingest metadata for local files from folder""" + client = Client(host=platform_host, token=platform_token) generator = FilesystemGenerator(host_settings="local") diff --git a/odd_cli/main.py b/odd_cli/main.py index c70d041..e13fe0c 100644 --- a/odd_cli/main.py +++ b/odd_cli/main.py @@ -3,25 +3,26 @@ from odd_dbt.app import app as dbt_test_app from odd_cli.__version__ import VERSION -from odd_cli.apps.metadata import app as collect_app +from odd_cli.apps.metadata import collect from odd_cli.apps.tokens import app as tokens_app + app = typer.Typer(pretty_exceptions_show_locals=False) -app.add_typer( - collect_app, -) -app.add_typer( - tokens_app, - name="tokens", -) +app.add_typer(tokens_app, name="tokens") app.add_typer(dbt_test_app, name="dbt") +# such solution was made to prevent subcommand nesting (2 collect words in a row) +# and save the modularity of commands +app.command()(collect) + + @app.command() def version( short: bool = typer.Option(False, "--short", "-s", help="Print only version number") ): - "Print version" + """Print version""" + if short: print(VERSION) else: diff --git a/tests/test_collect.py b/tests/test_collect.py index 968cf47..b36e335 100644 --- a/tests/test_collect.py +++ b/tests/test_collect.py @@ -10,7 +10,7 @@ runner = CliRunner() -@mock.patch("odd_cli.main.Client") +@mock.patch("odd_cli.client.Client") class CollectCommandTestCase(unittest.TestCase): def setUp(self) -> None: self.folder_path = str(Path(__file__).parent / "data")