From 1f47e615582675417d2307d6b19af2f284dca123 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Wed, 7 Sep 2022 13:52:09 -0400 Subject: [PATCH 1/7] refactor: Remove generate function from main; re-add it when more complete. --- gatorgrade/main.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/gatorgrade/main.py b/gatorgrade/main.py index 6aff2b06..c01470b3 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -55,26 +55,26 @@ def gatorgrade( sys.exit(FAILURE) -@app.command() -def generate( - root: Path = typer.Argument( - Path("."), - help="Root directory of the assignment", - exists=True, - dir_okay=True, - writable=True, - ), - paths: List[Path] = typer.Option( - ["*"], - help="Paths to recurse through and generate checks for", - exists=False, - ), -): - """Generate a gatorgrade.yml file.""" - targets = [] - for path in paths: - targets.extend(glob.iglob(path.as_posix(), recursive=True)) - generate_config(targets, root.as_posix()) +# @app.command() +# def generate( +# root: Path = typer.Argument( +# Path("."), +# help="Root directory of the assignment", +# exists=True, +# dir_okay=True, +# writable=True, +# ), +# paths: List[Path] = typer.Option( +# ["*"], +# help="Paths to recurse through and generate checks for", +# exists=False, +# ), +# ): +# """Generate a gatorgrade.yml file.""" +# targets = [] +# for path in paths: +# targets.extend(glob.iglob(path.as_posix(), recursive=True)) +# generate_config(targets, root.as_posix()) if __name__ == "__main__": From 565837aa2a9fb81ce0455c00764d8e82057e117f Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Wed, 7 Sep 2022 13:53:54 -0400 Subject: [PATCH 2/7] refactor: Comment out import statements in main used by generate_config. --- gatorgrade/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gatorgrade/main.py b/gatorgrade/main.py index c01470b3..4520c18e 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -1,14 +1,14 @@ """Use Typer to run gatorgrade to run the checks and generate the yml file.""" -import glob +# import glob import sys from pathlib import Path -from typing import List +# from typing import List import typer from rich.console import Console -from gatorgrade.generate.generate import generate_config +# from gatorgrade.generate.generate import generate_config from gatorgrade.input.parse_config import parse_config from gatorgrade.output.output import run_checks From eedfdece08437cc400e3f4bbcdf553b483fb8da3 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Wed, 7 Sep 2022 13:56:30 -0400 Subject: [PATCH 3/7] refactor: Comment out test cases in test_main for generate feature. --- tests/test_main.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 0923b23e..df96061d 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -58,25 +58,25 @@ def cleanup_files(monkeypatch): os.remove(file) -def test_generate_creates_valid_yml(): - """Ensure that the generate command creates the .yml file correctly.""" - result = runner.invoke(main.app, ["generate"]) - print(result.stdout) - assert result.exit_code == 0 +# def test_generate_creates_valid_yml(): +# """Ensure that the generate command creates the .yml file correctly.""" +# result = runner.invoke(main.app, ["generate"]) +# print(result.stdout) +# assert result.exit_code == 0 -def test_generate_fails_with_existing_yml(): - """Ensure that a second yml file isn't generated without the force command.""" - result = runner.invoke(main.app, ["generate"]) - print(result.stdout) - assert result.exit_code == 0 +# def test_generate_fails_with_existing_yml(): +# """Ensure that a second yml file isn't generated without the force command.""" +# result = runner.invoke(main.app, ["generate"]) +# print(result.stdout) +# assert result.exit_code == 0 -def test_generate_force_option_creates_yml(): - """Ensure that the force command works correctly.""" - result = runner.invoke(main.app, ["generate"]) - print(result.stdout) - assert result.exit_code == 0 +# def test_generate_force_option_creates_yml(): +# """Ensure that the force command works correctly.""" +# result = runner.invoke(main.app, ["generate"]) +# print(result.stdout) +# assert result.exit_code == 0 @pytest.mark.parametrize( From 655fb7e1e7161c1b15beb7d251ccf94d6e78ed57 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Wed, 7 Sep 2022 13:56:45 -0400 Subject: [PATCH 4/7] refactor: Delete commented-out import statements in main for generate_config. --- gatorgrade/main.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/gatorgrade/main.py b/gatorgrade/main.py index 4520c18e..5c81dab9 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -1,14 +1,11 @@ """Use Typer to run gatorgrade to run the checks and generate the yml file.""" -# import glob import sys from pathlib import Path -# from typing import List import typer from rich.console import Console -# from gatorgrade.generate.generate import generate_config from gatorgrade.input.parse_config import parse_config from gatorgrade.output.output import run_checks From 76bc1c5ab4a6c31da1ad85a25505f36fc9783b86 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Wed, 7 Sep 2022 13:57:59 -0400 Subject: [PATCH 5/7] coms: Add a missing word in a comment in gatorgrade function in main. --- gatorgrade/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatorgrade/main.py b/gatorgrade/main.py index 5c81dab9..d017221b 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -25,7 +25,7 @@ def gatorgrade( ctx: typer.Context, filename: Path = typer.Option(FILE, "--config", "-c", help="Name of the yml file."), ): - """Run the GatorGrader checks in the gatorgrade.yml file.""" + """Run the GatorGrader checks in the specified gatorgrade.yml file.""" # if ctx.subcommand is None then this means # that, by default, gatorgrade should run in checking mode if ctx.invoked_subcommand is None: From 8187f00014b381d8a19fa11d4192981ba19222b4 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Wed, 7 Sep 2022 14:13:40 -0400 Subject: [PATCH 6/7] fix: Capitalize abbrev. "YML" in help param for filename parameter in gatorgrade function in main. --- gatorgrade/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatorgrade/main.py b/gatorgrade/main.py index d017221b..f968b943 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -23,7 +23,7 @@ @app.callback(invoke_without_command=True) def gatorgrade( ctx: typer.Context, - filename: Path = typer.Option(FILE, "--config", "-c", help="Name of the yml file."), + filename: Path = typer.Option(FILE, "--config", "-c", help="Name of the YML file."), ): """Run the GatorGrader checks in the specified gatorgrade.yml file.""" # if ctx.subcommand is None then this means From 23b23ec97b7f1cc7510c88247f00ea319ea643a3 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Wed, 7 Sep 2022 14:15:14 -0400 Subject: [PATCH 7/7] feat: Improve help for typer app and add emoji in main help diagnostic in main. --- gatorgrade/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gatorgrade/main.py b/gatorgrade/main.py index f968b943..23fd8b04 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -10,7 +10,17 @@ from gatorgrade.output.output import run_checks # create an app for the Typer-based CLI -app = typer.Typer(add_completion=False) + +# define the emoji that will be prepended to the help message +gatorgrade_emoji = "🐊" + +# create a Typer app that +# --> does not support completion +# --> has a specified help message with an emoji +app = typer.Typer( + add_completion=False, + help=f"{gatorgrade_emoji} Run the GatorGrader checks in the specified gatorgrade.yml file.", +) # create a default console for printing with rich console = Console()