Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collect command requires duplication of collect word during invocation #6

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading