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

feat(#10, #11): filter cli command with params --repositores, --out #17

Merged
merged 3 commits into from
Apr 17, 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
32 changes: 20 additions & 12 deletions objects/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,28 @@

app = typer.Typer()

# @todo #1:45min Add support for --repositories and --out parameter.
# We should add support to our cli to handle two options: --repositories,
# and --out. Both indicate the name of the file to read/create.
# @todo #1:25min Clean parameters that we don't need.
# Let's remove parameters that we don't really need in this cli.
# Less parameters we will have, the better.
# Don't forget to remove this puzzle.
def _version_callback(value: bool) -> None:
if value:
typer.echo(f"{NAME} v{VERSION}")
typer.echo(f"{VERSION}")
raise typer.Exit()

@app.command()
def filter(
repositories: str = typer.Option(..., "--repositories", help="Path to the repositories file."),
out: str = typer.Option(..., "--out", help="Path to the output file.")
):
"""
Filter repositories.
"""
typer.echo(f"Filtering {repositories}...")
# @todo #10:45min Filter the repositories using general-like interface.
# We should execute filtering here using some general interface, so
# it would easy to use either LLM or ML filters.
# @todo #10:35min Create {out} file with output result.
# We should create file with provided name for {out}.
# Don't forget to remove this puzzle.
typer.echo(f"Saving output to {out}")


# Run it.
@app.callback()
Expand All @@ -51,14 +61,12 @@ def main(
version: Optional[bool] = typer.Option(
None,
"--version",
"-v",
help="Show the application's version and exit.",
callback=_version_callback,
is_eager=True,
)
) -> None:
"""
Respond in interface
:param version: Cli version
f"""
{NAME}
"""
return
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def version():
],
entry_points={
'console_scripts': [
'samples-filter=objects.run.py:main',
'samples-filter=objects.__main__.py:main',
],
},
author='Aliaksei Bialiauski',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""
from typer.testing import CliRunner

from objects import NAME, VERSION, cli
from objects import VERSION, cli

runner = CliRunner()

Expand All @@ -38,4 +38,4 @@ def test_displays_version():
"""
result = runner.invoke(cli.app, ["--version"])
assert result.exit_code == 0
assert f"{NAME} v{VERSION}\n" in result.stdout
assert f"{VERSION}\n" in result.stdout
Loading