From 7949a083faed647d018570da3673984643e7014c Mon Sep 17 00:00:00 2001 From: Tuck Williamson Date: Tue, 11 Nov 2025 16:41:35 -0500 Subject: [PATCH] Fixed #20 - the debug core file stuff needed to be moved into a subroutine. --- src/agh/cli.py | 65 +++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/src/agh/cli.py b/src/agh/cli.py index 9c9fea0..e3b7204 100644 --- a/src/agh/cli.py +++ b/src/agh/cli.py @@ -738,6 +738,41 @@ def run(args=None): cli_args = parser.parse_args(args=args) console.rule(f"[b i]agh[/] - Assignment Grading Helper - Version: [b i]{__version__}") + if cli_args.debug_core_files or cli_args.restore_default_core_location: + handleCore(cli_args) + + # Command handling. + match cli_args.command: + case "status": + assignment = getCurrentAssignment() + displayAssignmentInfo(cli_args) + displaySubmissionInfo(cli_args, assignment) + case "assignment": + handleAssignmentCmd(cli_args) + case "submission": + handleSubmissionCmd(cli_args) + case "run": + assignment = getCurrentAssignment() + try: + asyncio.run(execute_pytest_on_submissions(cli_args, assignment)) + except KeyboardInterrupt: + pass + case "test": + assignment = getCurrentAssignment() + asyncio.run(execute_pytest_on_submissions(cli_args, assignment, extra_pytest_args='-m "not build and not render"')) + case "build": + assignment = getCurrentAssignment() + asyncio.run(execute_pytest_on_submissions(cli_args, assignment, extra_pytest_args='-m "build"')) + case "render": + assignment = getCurrentAssignment() + asyncio.run(execute_pytest_on_submissions(cli_args, assignment, extra_pytest_args='-m "render"')) + case _: + console.log(cli_args, style="error") + # print(start(args)) + parser.exit(0) + + +def handleCore(cli_args: argparse.Namespace): # Core file Handling. prior_pattern_path = getCurrentAssignment().root_directory / ".prior_core_pattern.txt" core_pattern_path = Path("/proc/sys/kernel/core_pattern") @@ -776,36 +811,6 @@ def run(args=None): console.print(f"[bold green]Core dump location restored to '{prior_loc}'") exit(0) - # Command handling. - match cli_args.command: - case "status": - assignment = getCurrentAssignment() - displayAssignmentInfo(cli_args) - displaySubmissionInfo(cli_args, assignment) - case "assignment": - handleAssignmentCmd(cli_args) - case "submission": - handleSubmissionCmd(cli_args) - case "run": - assignment = getCurrentAssignment() - try: - asyncio.run(execute_pytest_on_submissions(cli_args, assignment)) - except KeyboardInterrupt: - pass - case "test": - assignment = getCurrentAssignment() - asyncio.run(execute_pytest_on_submissions(cli_args, assignment, extra_pytest_args='-m "not build and not render"')) - case "build": - assignment = getCurrentAssignment() - asyncio.run(execute_pytest_on_submissions(cli_args, assignment, extra_pytest_args='-m "build"')) - case "render": - assignment = getCurrentAssignment() - asyncio.run(execute_pytest_on_submissions(cli_args, assignment, extra_pytest_args='-m "render"')) - case _: - console.log(cli_args, style="error") - # print(start(args)) - parser.exit(0) - # todo: create custom url scheme so I can run things from links in the output. # To create a custom URL scheme in Ubuntu that executes a command in the terminal, you need to define a desktop