Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 17, 2024
2 parents c43227f + ad3b098 commit d4933eb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
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

4 comments on commit d4933eb

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on d4933eb Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1-5b932efb disappeared from objects/cli.py), that's why I closed #10. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on d4933eb Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1-ce00ea3a disappeared from objects/cli.py), that's why I closed #11. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on d4933eb Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 10-1fb8be50 discovered in objects/cli.py) and submitted as #18. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on d4933eb Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 10-3a34afdb discovered in objects/cli.py) and submitted as #19. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.