Skip to content

Commit

Permalink
#33 Minor changes to help messages and logging, by Piotr
Browse files Browse the repository at this point in the history
  • Loading branch information
caseneuve committed Jun 2, 2023
1 parent f62a641 commit f12876e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions cli/students.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get(
),
sort: bool = typer.Option(False, "-s", "--sort", help="Sort alphabetically"),
sort_reverse: bool = typer.Option(
False, "-r", "--reverse", help="Sort in reverse order"
False, "-r", "--reverse", help="Sort alphabetically in reverse order"
),
):
"""
Expand Down Expand Up @@ -83,8 +83,6 @@ def holidays(
students = api.get()

if not students:
if not quiet:
typer.echo("No students found!")
sys.exit(1)

result = 0 if all(api.delete(s) for s in students) else 1
Expand Down
4 changes: 3 additions & 1 deletion pythonanywhere/students.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def get(self):
try:
result = self.api.get()
student_usernames = [student["username"] for student in result["students"]]
logger.info(snakesay(f"{len(student_usernames)} students found!"))
count = len(student_usernames)
msg = f"You have {count} students!" if count else "Currently you don't have any students."
logger.info(snakesay(msg))
return student_usernames
except Exception as e:
logger.warning(snakesay(str(e)))
Expand Down
1 change: 0 additions & 1 deletion tests/test_cli_students.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,3 @@ def test_exits_with_error_when_none_student_removed(

assert result.exit_code == 1
assert not mock_students_delete.called
assert "No students found" in result.stdout

0 comments on commit f12876e

Please sign in to comment.