Skip to content

Commit e3cca57

Browse files
committed
cli add stdin
1 parent 1f6496e commit e3cca57

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

commit0/cli.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import subprocess
1515
import yaml
1616
import os
17-
17+
import sys
1818
commit0_app = typer.Typer(
1919
no_args_is_help=True,
2020
add_completion=False,
@@ -209,7 +209,7 @@ def test(
209209
..., help="Directory of the repository to test"
210210
),
211211
test_ids: str = typer.Argument(
212-
...,
212+
None,
213213
help='All ways pytest supports to run and select tests. Please provide a single string. Example: "test_mod.py", "testing/", "test_mod.py::test_func", "-k \'MyClass and not method\'"',
214214
),
215215
branch: Union[str, None] = typer.Option(
@@ -238,6 +238,7 @@ def test(
238238
help="Set this to 2 for more logging information",
239239
count=True,
240240
),
241+
stdin: bool = typer.Option(False, "--stdin", help="Read test names from stdin"),
241242
) -> None:
242243
"""Run tests on a Commit0 repository."""
243244
check_commit0_path()
@@ -255,6 +256,13 @@ def test(
255256
)
256257
branch = get_active_branch(git_path)
257258

259+
if stdin:
260+
# Read test names from stdin
261+
test_ids = sys.stdin.read().strip()
262+
elif test_ids is None:
263+
typer.echo("Error: test_ids must be provided or use --stdin option", err=True)
264+
raise typer.Exit(code=1)
265+
258266
if verbose == 2:
259267
typer.echo(f"Running tests for repository: {repo_or_repo_path}")
260268
typer.echo(f"Branch: {branch}")
@@ -276,6 +284,7 @@ def test(
276284
)
277285

278286

287+
279288
@commit0_app.command()
280289
def evaluate(
281290
branch: Union[str, None] = typer.Option(

0 commit comments

Comments
 (0)