diff --git a/gatorgrade/main.py b/gatorgrade/main.py index 6aff2b06..23fd8b04 100644 --- a/gatorgrade/main.py +++ b/gatorgrade/main.py @@ -1,19 +1,26 @@ """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 # 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() @@ -26,9 +33,9 @@ @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 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: @@ -55,26 +62,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__": 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(