Skip to content

Commit

Permalink
change error communication to sys.exit #7
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipMay committed Jul 6, 2021
1 parent 01b46d9 commit 5930482
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions style_doc/style_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,12 @@ def style_doc_files(*files, max_len=119, check_only=False, py_only=False, rst_on
def main(*files, max_len=119, check_only=False, py_only=False, rst_only=False):
if py_only and rst_only:
print("You must not set --py_only and --rst_only at the same time.")
sys.exit(1)
sys.exit(2)

changed = style_doc_files(*files, max_len=max_len, check_only=check_only, py_only=py_only, rst_only=rst_only)
if check_only and len(changed) > 0:
raise ValueError(f"{len(changed)} files should be restyled!")
print(f"{len(changed)} files should be restyled!")
sys.exit(1)
elif len(changed) > 0:
print(f"Cleaned {len(changed)} files!")

Expand Down

0 comments on commit 5930482

Please sign in to comment.