|
26 | 26 | import smtcomp.selection |
27 | 27 | from smtcomp.unpack import write_cin, read_cin |
28 | 28 | import smtcomp.scramble_benchmarks |
| 29 | +from rich.console import Console |
29 | 30 |
|
30 | 31 | app = typer.Typer() |
31 | 32 |
|
32 | 33 |
|
33 | 34 | @app.command() |
34 | | -def show(file: str) -> None: |
| 35 | +def show( |
| 36 | + files: list[Path] = typer.Argument(None), |
| 37 | + into_comment_file: Annotated[Optional[Path], typer.Option(help="Write the summary into the given file")] = None, |
| 38 | +) -> None: |
35 | 39 | """ |
36 | 40 | Show information about a solver submission |
37 | 41 | """ |
38 | | - s = None |
39 | | - try: |
40 | | - s = submission.read(file) |
41 | | - except Exception as e: |
42 | | - rich.print(f"[red]Error during file parsing of {file}[/red]") |
43 | | - print(e) |
44 | | - exit(1) |
45 | | - if not s: |
46 | | - rich.print(f"[red]Empty submission??? {file}[/red]") |
47 | | - exit(1) |
48 | | - submission.show(s) |
49 | 42 |
|
| 43 | + def read_submission(file: Path) -> defs.Submission: |
| 44 | + try: |
| 45 | + return submission.read(str(file)) |
| 46 | + except Exception as e: |
| 47 | + rich.print(f"[red]Error during file parsing of {file}[/red]") |
| 48 | + print(e) |
| 49 | + exit(1) |
| 50 | + |
| 51 | + l = list(map(read_submission, files)) |
| 52 | + |
| 53 | + console = Console(record=into_comment_file is not None) |
| 54 | + if into_comment_file is not None: |
| 55 | + console.print("<details><summary>Summary of modified submissions</summary>") |
| 56 | + for s in l: |
| 57 | + if into_comment_file is not None: |
| 58 | + console.print("") |
| 59 | + console.print("```") |
| 60 | + t = submission.tree_summary(s) |
| 61 | + console.print(t) |
| 62 | + if into_comment_file is not None: |
| 63 | + console.print("```") |
| 64 | + if into_comment_file is not None: |
| 65 | + console.print("</details>") |
| 66 | + |
| 67 | + if into_comment_file is not None: |
| 68 | + if len(l) > 0: |
| 69 | + into_comment_file.write_text(console.export_text()) |
| 70 | + else: |
| 71 | + into_comment_file.write_text("") |
50 | 72 |
|
51 | 73 | @app.command() |
52 | 74 | def validate(file: str) -> None: |
|
0 commit comments