Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the --help menu and add the --version and -v flags to the command-line interface #105

Open
wants to merge 230 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
230 commits
Select commit Hold shift + click to select a range
df8df34
Add JSON output with "--report" or "-r" flags.
ullrichd21 Jul 28, 2022
6d7d223
Fix test to support returned tuple.
ullrichd21 Aug 23, 2022
6c0ee64
Fix codestyle/linting.
ullrichd21 Aug 23, 2022
feae40d
Fix codestyle/linting, add encoding type.
ullrichd21 Aug 23, 2022
58dc7c2
Fix codestyle/linting.
ullrichd21 Aug 23, 2022
44fcc81
feat: Add draft of new help message with version info in main.
gkapfham Sep 8, 2022
50b5e61
feat: Add version module with get_gatorgrade_version and
gkapfham Sep 8, 2022
d779154
fix: Refine the phrase in the epilog_message in main.
gkapfham Sep 8, 2022
babc827
refactor: Reorganize gatorgrade function in main to handle version
gkapfham Sep 8, 2022
04a29e9
fix: Delete the extra help_message not needed in main module.
gkapfham Sep 8, 2022
e95731a
feat: Add get_project_version and refactor version functions.
gkapfham Sep 9, 2022
8372f9f
refactor: Use improved markdown version strings in the main module.
gkapfham Sep 9, 2022
b2a7f61
refactor: Remove a not-needed and commented-out global message in main.
gkapfham Sep 9, 2022
6063901
feat: Add constants and all projects in PROJECTS list in version.
gkapfham Sep 9, 2022
573e44a
refactor: Further improve help and epilog messages in main.
gkapfham Sep 9, 2022
ce82d5b
fix: Remove spaces in a multi-line string in main.
gkapfham Sep 9, 2022
d02d49b
fix: Remove spaces in a multi-line string in main.
gkapfham Sep 9, 2022
da47102
refactor: Add version module in the util package.
gkapfham Sep 9, 2022
e67be95
refactor: Rewrite import for version to be in gatorgrade.util in main.
gkapfham Sep 9, 2022
a36cb57
refactor: Delete the version module in top-level package.
gkapfham Sep 9, 2022
bf92c80
coms: Add two and update one comment in main module.
gkapfham Sep 9, 2022
b890e10
fix: Delete conditional logic on help that was not needed in main.
gkapfham Sep 9, 2022
9d01e2b
feat: Add draft of the --version output in main.
gkapfham Sep 10, 2022
df32e7c
feat: Add versions module in util to not conflict with --version in
gkapfham Sep 10, 2022
9940fa0
refactor: Remove version module that conflicts with --version in main.
gkapfham Sep 10, 2022
93f0237
feat: Improve the help_message_markdown in main.
gkapfham Sep 10, 2022
07495e2
coms: Improve a comment in gatorgrade function in main.
gkapfham Sep 10, 2022
8ab46d8
refactor: Make the variable GATORGRADE_EMOJI in main module constants.
gkapfham Sep 10, 2022
a1ff3ec
feat: Improve main so that github_message is generated.
gkapfham Sep 10, 2022
fc0a4f3
style: Reformat the source code in versions.
gkapfham Sep 10, 2022
b72c6ee
feat: Add the github module in util with get_github_projects function.
gkapfham Sep 10, 2022
9b15c73
refactor: Use the GATORGRADE_EMOJI_RICH constant in main.
gkapfham Sep 10, 2022
3dda163
fix: Delete not-needed variables for GitHub projects in main.
gkapfham Sep 10, 2022
a9d9a99
refactor: Use the RICH_MARKUP_MODE_DEFAULT constant in main.
gkapfham Sep 10, 2022
18e977e
chore: Increase minimal version of Python to 3.8 in pyproject.toml.
gkapfham Sep 10, 2022
4528f52
chore: Use Python 3.8 and 3.10 on ubuntu-latest and 3.9 on macos-latest
gkapfham Sep 10, 2022
0070a2b
chore: Bump the poetry-version to 1.2 in the main.yml file.
gkapfham Sep 10, 2022
12808aa
chore: Update poetry.lock file to reflect move to Python 3.8 minimum.
gkapfham Sep 10, 2022
02c1231
fix: Revert/increment poetry-version in main.yml to 1.1.14 as 1.2 fails.
gkapfham Sep 10, 2022
726a864
Merge branch 'main' into feat/add-version
gkapfham Sep 10, 2022
bf24b98
chore: Specify Python 3.8 as the minimum version in publish.yml.
gkapfham Sep 10, 2022
7bce6fb
Merge branch 'main' into feat/add-version
gkapfham Sep 19, 2022
7bfa554
coms: Add a comment to versions to explain PROJECTS variable.
gkapfham Sep 19, 2022
5e80c32
coms: Fix an incorrect docstring in the versions module.
gkapfham Sep 19, 2022
dd4de85
coms: Add comments to explain steps in the get_project_versions in ve…
gkapfham Sep 19, 2022
ad8b4d9
refactor: Delete two not-needed functions in the versions module.
gkapfham Sep 19, 2022
ba76bbf
fix: Stop using an epilog in main and add more to version output.
gkapfham Sep 19, 2022
4499728
feat: Improve the output of --version in the main module.
gkapfham Sep 19, 2022
6d7b904
coms: Improve two comments in the main module.
gkapfham Sep 19, 2022
2bb8c01
fix: Delete the GATORGRADE_EMOJI constant in main.
gkapfham Sep 19, 2022
6fc26d7
refactor: Delete a not-needed variable in main.
gkapfham Sep 19, 2022
87d4587
coms: Add comments to explain steps in get_github_projects in github.
gkapfham Sep 19, 2022
e52e20a
coms: Delete a not-needed comment for typer app in main.
gkapfham Sep 19, 2022
5af4b70
coms: Clarify the docstring comment in main.
gkapfham Sep 19, 2022
a5850e2
chore: Bump the semver in the pyproject.toml file.
gkapfham Sep 19, 2022
c31b6e9
upgrade python version to unification
Yanqiao4396 Oct 17, 2022
7e277af
Update GatorGrader version and regenerate poetry.lock with new versions
Michionlion Oct 17, 2022
b96ff26
Merge pull request #108 from GatorEducator/update-python-version
Michionlion Oct 17, 2022
edb3c79
Merge branch 'main' of github.com:GatorEducator/gatorgrade into featu…
burgess01 Jan 24, 2023
d2d8744
feature: remove files no longer in main
burgess01 Jan 26, 2023
5b29537
feature: make the report file param more robust
burgess01 Jan 26, 2023
6ff5df9
feature: create funct to create checks json file
burgess01 Jan 26, 2023
b881e70
feature: adjust tests to account for file param
burgess01 Jan 26, 2023
2bee0f1
docs: add insights json file to test repo
burgess01 Jan 26, 2023
af75722
feature: update json to have more check info
burgess01 Jan 27, 2023
52dffed
feature: incorporate md conversion from json
burgess01 Jan 27, 2023
ab626fe
feature: give more info about failing checks
burgess01 Jan 27, 2023
a59335d
docs: correct md converter docstring
burgess01 Jan 27, 2023
5c1043b
Bug fix: delete one line in out
Yanqiao4396 Jan 28, 2023
bcdbd86
feature: rework json and md funcs
burgess01 Jan 30, 2023
d63860a
feature: rework json and md funcs
burgess01 Jan 30, 2023
cdd6378
fix: correct missing -- in tag catch
burgess01 Jan 30, 2023
d134db0
docs: update test json and md files
burgess01 Jan 30, 2023
86fb853
fix: rework icons to pass in windows
burgess01 Jan 30, 2023
f057069
fix: remove font to fix windows error
burgess01 Jan 30, 2023
0c7a1d0
fix: encode md file to fix windows error
burgess01 Jan 30, 2023
bbbf02e
feature: make report a bool instead of Path
burgess01 Jan 31, 2023
6cf575d
feature: refactor functions to not use files
burgess01 Jan 31, 2023
bf39dd4
feature: remove json and md files from test cases
burgess01 Jan 31, 2023
11b72e4
docs: correct function docstrings
burgess01 Jan 31, 2023
25ceecb
docs: add test cases for json and md files
burgess01 Feb 1, 2023
d5c3d70
docs: add os import for test case file removal
burgess01 Feb 1, 2023
cd85352
feature: add tuple based cli functionality
burgess01 Feb 1, 2023
3c592e2
feature: add function to interpret tuple cli
burgess01 Feb 1, 2023
d3caf61
fix: close files to avoid windows issues
burgess01 Feb 1, 2023
a9ad06f
fix: encode file for windows compatibility
burgess01 Feb 1, 2023
762d46b
fix: refactor md test case to work on all os
burgess01 Feb 1, 2023
7a0d4d8
Add env feature
Yanqiao4396 Feb 1, 2023
972c651
Add help codes
Yanqiao4396 Feb 1, 2023
71fd4d8
Bug fix
Yanqiao4396 Feb 1, 2023
9cbc9c2
fix: change logic to pass test cases
burgess01 Feb 1, 2023
2860260
fix: correct black linting error in output.py
burgess01 Feb 1, 2023
bf3b31f
feature: change any func call to all
burgess01 Feb 1, 2023
e5acb4e
Add test for case of invalid path input
Yanqiao4396 Feb 1, 2023
964a2a4
Refactor json format
Yanqiao4396 Feb 5, 2023
131f102
Change related test
Yanqiao4396 Feb 5, 2023
52329d2
Correct Lint
Yanqiao4396 Feb 6, 2023
04a90e4
fix quote sign to double for json generation
Yanqiao4396 Feb 6, 2023
dcc09e8
feature: change format of md file output
burgess01 Feb 9, 2023
2996b25
feature: edit formatting of md file failed checks
burgess01 Feb 9, 2023
79e295e
feature: add param to both check classes
burgess01 Feb 10, 2023
eaae271
feature: incorporate new param into class creation
burgess01 Feb 10, 2023
bdf54ad
feature: add json param to result class
burgess01 Feb 10, 2023
5174803
feature: update output to work w new class struct
burgess01 Feb 10, 2023
8af0358
feature: rework json/md funcs to use new classes
burgess01 Feb 10, 2023
afcc8a5
feature: correct linting
burgess01 Feb 10, 2023
3ace966
Add new test
Yanqiao4396 Feb 10, 2023
c5106d7
fix: reformat using black
burgess01 Feb 13, 2023
d5746e1
fix: correct json test case
burgess01 Feb 13, 2023
ba1dffe
Fix: check box in failing section in md
Yanqiao4396 Feb 13, 2023
2392b91
Fox: env variable create
Yanqiao4396 Feb 14, 2023
eebf48e
Fix: change back
Yanqiao4396 Feb 14, 2023
79379aa
Fix: env variable creation in github action
Yanqiao4396 Feb 14, 2023
82ef9c0
docs: add comment for --help
Yanqiao4396 Feb 14, 2023
212dfca
feature: include project name in md output
burgess01 Feb 14, 2023
e23d353
docs: update test case for md output change
burgess01 Feb 14, 2023
6b443db
feature: readd previous changes
burgess01 Feb 14, 2023
37129d9
feature: combine amt and % lines, fix tests
burgess01 Feb 14, 2023
368eadf
bug: fix display diagnosis msg in terminal
Yanqiao4396 Feb 19, 2023
27703c6
Feat: add diagnostic message in js and md output
Yanqiao4396 Feb 25, 2023
9727e6e
Factor: lint fix
Yanqiao4396 Feb 25, 2023
720312b
Merge pull request #111 from GatorEducator/feature/json-output
burgess01 Mar 3, 2023
cb9e465
Merge pull request #113 from GatorEducator/bug/display-diagnosis
burgess01 Mar 3, 2023
d90ea1a
Delete malicious link
Yanqiao4396 Mar 15, 2023
b492c28
Add new hint
Yanqiao4396 Mar 15, 2023
41e5675
Factor: Fix markdown lint
Yanqiao4396 Mar 15, 2023
900fad4
Docs: remove meangingless hint
Yanqiao4396 Mar 15, 2023
6ef8f61
Merge pull request #115 from GatorEducator/Docs/Improve-README
Yanqiao4396 Mar 16, 2023
0063953
Bug: Upgrade poetry ver for http incompatibility
Yanqiao4396 May 22, 2023
2982b96
Bug: pin urll3 <=2.0
Yanqiao4396 May 22, 2023
9cc0dd4
Bug: pin urllib3 lower than 2 by pip
Yanqiao4396 May 22, 2023
e4b5f8a
Bug: Upgrade Poetry version to newest
Yanqiao4396 May 22, 2023
b87dcb0
Factor: Remove useless comment
Yanqiao4396 May 22, 2023
4c4a911
Bug: Remove urllab3 dep in pyproject.toml
Yanqiao4396 May 23, 2023
5148d74
Feat: Upgrade Poetry to 1.5.0
Yanqiao4396 May 23, 2023
42541d6
Merge pull request #117 from GatorEducator/HTTP-incompatibility
Yanqiao4396 Jun 6, 2023
e66535f
Bug: upgrade setup-poetry
Yanqiao4396 Jun 7, 2023
f1baed4
Merge pull request #120 from GatorEducator/bug/poetry-build-fail
Yanqiao4396 Jun 7, 2023
dff448f
Bug: mkdocs poetry update to v8
Yanqiao4396 Jun 23, 2023
9b07fda
Refac: distinguish json report from md report
Yanqiao4396 Jun 23, 2023
dd6fdb1
Feat: add json report in the github env
Yanqiao4396 Jun 23, 2023
148b424
Merge branch 'main' into feat/add-env-to-github-env
Yanqiao4396 Jun 23, 2023
980e0dd
update poetry build to v8 in publish.yml
Yanqiao4396 Jun 23, 2023
7e1851a
Refact: put file write code into a func
Yanqiao4396 Jun 24, 2023
21273ae
Add new test for the refactor
Yanqiao4396 Jun 24, 2023
4d07114
Feat: always add json_report into github_env
Yanqiao4396 Jun 24, 2023
0ef2833
Feat: json dump replace dumps with test
Yanqiao4396 Jun 24, 2023
5b189fd
Test: add test for file write related code
Yanqiao4396 Jun 24, 2023
290db19
Merge pull request #121 from GatorEducator/bug/poetry-build-fail
Yanqiao4396 Jun 26, 2023
4a8e29b
Merge branch 'main' into feat/add-env-to-github-env
Yanqiao4396 Jun 26, 2023
d49bf72
Merge pull request #122 from GatorEducator/feat/add-env-to-github-env
Yanqiao4396 Jun 26, 2023
269986f
Bug: json dumps replaces str
Yanqiao4396 Jun 27, 2023
8d555c7
Remove indent
Yanqiao4396 Jun 28, 2023
e583e7b
Merge pull request #123 from GatorEducator/bug/JSON_REPORT-dumps
Yanqiao4396 Jul 4, 2023
29d9c4f
Feat: add path in json_inf of CheckResult
Yanqiao4396 Jul 6, 2023
ebb536a
Test: customized json inf will be stored in report
Yanqiao4396 Jul 6, 2023
3ce6ab5
Bug: all front slash replacing back slash
Yanqiao4396 Jul 6, 2023
7648537
Bug: not have path attribute if path value is none
Yanqiao4396 Jul 6, 2023
2e091fd
Merge pull request #124 from GatorEducator/feat/add-path-to-report
Yanqiao4396 Jul 7, 2023
7761afc
Feat: add current time to report
Yanqiao4396 Jul 7, 2023
11ead19
Merge pull request #125 from GatorEducator/feat/time-in-report
Yanqiao4396 Jul 10, 2023
2131ff1
chore: Start to use python-version 3.10 in publish.yml.
gkapfham Dec 6, 2023
ed361df
chore: Improve a name of a step in publish.yml.
gkapfham Dec 6, 2023
965ea72
chore: Add the poetry-version attribute to 1.5.0 in publish.yml
gkapfham Dec 6, 2023
4f315d9
chore: Adopt a different approach for installing poetry in publish.yml.
gkapfham Dec 6, 2023
c9ef4b2
feat: added command printing code in output.py
rebekahrudd Sep 25, 2024
751c9ad
fix: deleted an extra variable assignment in output.py
rebekahrudd Sep 25, 2024
14ebc2a
fix: deleted extra comments in output.py
rebekahrudd Sep 25, 2024
393a667
refactor: Make the diagnostics message for failing command shorter in…
gkapfham Sep 27, 2024
c432c93
chore: Update the poetry.lock file with new dependencies.
gkapfham Sep 27, 2024
0296866
chore: Bump the semver (it was 0.0.0, starting to use it again) in th…
gkapfham Sep 27, 2024
74726f8
Merge branch 'feat/add-failing-command-diag'
gkapfham Sep 27, 2024
79a13ac
fix: implementation of output code and added feature in output.py
rebekahrudd Sep 30, 2024
dab0a1f
fix: command output added for GatorGraderCheck in output.py in fork
rebekahrudd Oct 2, 2024
0807781
fix: made failed_results subscriptable again in output.py
rebekahrudd Oct 3, 2024
ca4f9ba
deleted: print statements in test_main.py and test_output.py
rebekahrudd Oct 3, 2024
5205921
fix: reformatted output.py, test_output.py, and test_main.py
rebekahrudd Oct 3, 2024
6d114ef
fix: import formatting in test_output.py
rebekahrudd Oct 3, 2024
355f1a9
fix: update the over general exceptions to pass linting checks in .py…
rebekahrudd Oct 3, 2024
6f9d280
style: added an encoding type to the open file function in output.py
rebekahrudd Oct 3, 2024
b81b548
chore: Add the poetry.toml file to the .gitignore file.
gkapfham Oct 3, 2024
4ce148f
chore: add a newline after command output in output.py
rebekahrudd Oct 3, 2024
b3563a1
delete: an unecessary comment in test_main.py
rebekahrudd Oct 3, 2024
3d66d4e
debug: Comment out code for testing purposes in gatorgrade/output/out…
gkapfham Oct 3, 2024
c15bcca
Merge branch 'fix/report_bug' of github.com:GatorEducator/gatorgrade …
gkapfham Oct 3, 2024
b6563dd
debug: Uncomment lines in the gatorgrade/output/output.py file for te…
gkapfham Oct 3, 2024
ccf4837
fix: ran poetry linter to fix formatting in output.py
rebekahrudd Oct 3, 2024
f4c2b90
refactor: Remove the console.print() statements not needed in gatorgr…
gkapfham Oct 5, 2024
6a8ba6a
Merge branch 'fix/report_bug' of github.com:GatorEducator/gatorgrade …
gkapfham Oct 5, 2024
09dd6ac
style: Remove the inconsistent and not-needed blank lines in gatorgra…
gkapfham Oct 5, 2024
2d88ba9
style: Remove a not-needed import and blank lines and reorganize impo…
gkapfham Oct 5, 2024
e73c5ef
style: Remove not-needed blank lines in the gatorgrade/output/output.…
gkapfham Oct 5, 2024
843003a
chore: Bump the semver to 0.7.0 in the pyproject.toml file and upgrad…
gkapfham Oct 5, 2024
19f5a28
style: Resort the imports according to isort as a stopgap measure for…
gkapfham Oct 5, 2024
ddec9e9
chore: Update the poetry.lock file with new dependencies.
gkapfham Oct 5, 2024
467f815
refactor: Try a new approach to saving the failing commands in gatorg…
gkapfham Oct 5, 2024
47f0f9b
refactor: Add a run_command as an null string as a field in gatorgrad…
gkapfham Oct 5, 2024
15d593c
refactor: Comment out not-needed code and repair linting mistakes in …
gkapfham Oct 5, 2024
a6f63a0
coms: Add more explanatory comments to gatorgrade/output/output.py.
gkapfham Oct 5, 2024
ef5cfa7
style: Remove the not-needed blank lines in the gatorgrade/output/out…
gkapfham Oct 5, 2024
bc6edd3
style: Reformat all source code in gatorgrade/generate/generate.py wi…
gkapfham Oct 5, 2024
c74f32d
style: Reformat the gatorgrade/input/checks.py file to address ruff r…
gkapfham Oct 5, 2024
cbaad0f
fix: Delete variable(s) that are not used in the gatorgrade/output/ou…
gkapfham Oct 5, 2024
3d56e2b
chore: Add new task and project details and dependencies to the pypro…
gkapfham Oct 5, 2024
0f416d2
chore: Add the poetry.lock file with the new dependencies.
gkapfham Oct 5, 2024
d0e107c
fix: Remove an incorrect type annotation for a return of a function i…
gkapfham Oct 5, 2024
2052fa2
chore: Add type ignore pragmas to the gatorgrade/input/checks.py file.
gkapfham Oct 5, 2024
2f4e1fb
chore: Add type ignore pragmas to the gatorgrade/output/output.py file.
gkapfham Oct 5, 2024
4e202c7
fix: Use the Union type as part of an annotation to the gatorgrade/ou…
gkapfham Oct 5, 2024
3d2254e
fix: Add the correct type annotation for a list in the gatorgrade/inp…
gkapfham Oct 5, 2024
ca1e099
chore: Delete the use of symbex in the pyproject.toml file because no…
gkapfham Oct 5, 2024
3716063
test: Delete flaky tests in tests/output/test_output.py that do not h…
gkapfham Oct 5, 2024
9fa9940
test: Delete a not-needed capsys in the tests/output/test_output.py f…
gkapfham Oct 5, 2024
4b68877
chore: Add mypy to dev dependencies group in pyproject.toml and updat…
gkapfham Oct 5, 2024
221cea1
chore: Add mypy to and types-pyyaml to pyproject.toml and improve for…
gkapfham Oct 5, 2024
d0931df
chore: Update the poetry.lock file with new dependencies.
gkapfham Oct 5, 2024
0301a8e
chore: Check the matrix.os to prevent tests being run on Windows in .…
gkapfham Oct 5, 2024
faf57b8
refactor: Improve the implementation of a function in gatorgrade/outp…
gkapfham Oct 5, 2024
96e2e80
coms: Add more comments to the gatorgrade/output/output.py file.
gkapfham Oct 5, 2024
cc1ffd8
refactor: Do not attempt to save to GITHUB_STEP_SUMMARY if it does no…
gkapfham Oct 5, 2024
e642eec
style: Reformat source code to meet ruff standards in gatorgrade/outp…
gkapfham Oct 5, 2024
12fd209
chore: Add @rebekahrudd as a contributor in the pyproject.toml file.
gkapfham Oct 5, 2024
5299c29
Merge branch 'fix/report_bug'
gkapfham Oct 5, 2024
0169799
chore: Delete the mkdocs.yml file as no longer building a web site an…
gkapfham Oct 5, 2024
78fc5c8
feat: defined command output in check_result.py
rebekahrudd Nov 5, 2024
b8a680c
fix: changed the color of the failing command output in check_result.py
rebekahrudd Nov 19, 2024
5ae5e8d
Merge branch 'feat/add-version' of github.com:GatorEducator/gatorgrad…
rebekahrudd Nov 22, 2024
74d3913
feat: added version to the command line in main.py
rebekahrudd Nov 22, 2024
4db13d0
format: main.py file reformatted
rebekahrudd Nov 22, 2024
c1072ac
format: main.pr reformatted
rebekahrudd Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add JSON output with "--report" or "-r" flags.
  • Loading branch information
ullrichd21 committed Jul 28, 2022
commit df8df347efe19ff583dcddba2bc6b3eeec4bf17d
4 changes: 2 additions & 2 deletions gatorgrade/main.py
Original file line number Diff line number Diff line change
@@ -18,13 +18,13 @@
def gatorgrade(
ctx: typer.Context,
filename: Path = typer.Option(FILE, "--config", "-c", help="Name of the yml file."),
report: Path = typer.Option(None, "--report", "-r", help="Name of the report file"),
):
"""Run the GatorGrader checks in the gatorgrade.yml file."""
# check if ctx.subcommand is none
if ctx.invoked_subcommand is None:
checks = parse_config(filename)
run_and_display_command_checks(checks)

run_and_display_command_checks(checks, report=report)

@app.command()
def generate(
28 changes: 21 additions & 7 deletions gatorgrade/output/output_functions.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@
for the output team. For instance, functions dealing with percentage
output, description output, and colorization of text.
"""
import json
import traceback

import typer
import gator
from gatorgrade.output import output_percentage_printing
@@ -48,15 +51,15 @@ def run_commands_and_return_results(commands_input):
try:
result = gator.grader(command)
# disable pylint so the more general Exception class can be used
except Exception as command_exception: # pylint: disable=W0703
bad_command = command_exception.__class__
result = (command, False, bad_command)
except Exception: # pylint: disable=W0703
# bad_command = command_exception.__class__
result = (command, False, traceback.format_exc())
results.append(result)

return results


def display_check_results(results):
def display_check_results(results, output_file=None):
"""
Process results and determine if the check passed or failed.

@@ -76,6 +79,10 @@ def display_check_results(results):
output_passed_checks(passed_checks)
output_failed_checks(failed_checks)

if output_file is not None:
return passed_checks, failed_checks
return None, None


def output_passed_checks(passed_checks):
"""Output the results for all of the checks that passed using the passed_checks list."""
@@ -98,7 +105,7 @@ def output_failed_checks(failed_checks):
typer.secho(f" \u2192 {description}", fg=typer.colors.YELLOW)


def run_and_display_command_checks(commands):
def run_and_display_command_checks(commands, report=None):
"""Run commands through GatorGrader and display them to the user.

Args:
@@ -116,5 +123,12 @@ def run_and_display_command_checks(commands):
'--arg', '1', '--directory', './home', '--file', 'file.py']]}
"""
results = run_commands_and_return_results(commands)
display_check_results(results)
typer.echo(output_percentage_printing.print_percentage(results))
passed_checks, failed_checks = display_check_results(results, output_file=report)
percent_string, percent = output_percentage_printing.print_percentage(results)
typer.echo(percent_string)

if report is not None:
r = {"passed_checks": passed_checks, "failed_checks": failed_checks, "percent": percent}
with open(report, "w") as f:
f.write(json.dumps(r))
f.close()
3 changes: 1 addition & 2 deletions gatorgrade/output/output_percentage_printing.py
Original file line number Diff line number Diff line change
@@ -27,5 +27,4 @@ def print_percentage(results):
f"Passing {len(true_list)}/{len(results)}, Grade is {percent}%.",
fg=typer.colors.RED,
)

return result
return result, percent