Skip to content

Commit

Permalink
Fix collect command requires duplication of collect word during invok…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
Valerii Mironchenko committed Jun 10, 2024
1 parent 7ec2009 commit c93330c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.fleet/
.vscode/
.vscode/

*.DS_Store
9 changes: 2 additions & 7 deletions odd_cli/apps/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,16 @@
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"),
platform_token: str = typer.Option(
..., "--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")
Expand Down
19 changes: 10 additions & 9 deletions odd_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c93330c

Please sign in to comment.