Skip to content

Commit

Permalink
Allow cylc lint to output error code if issues found
Browse files Browse the repository at this point in the history
  • Loading branch information
ColemanTom committed May 16, 2023
1 parent 3b01d80 commit 8c7a2ec
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cylc/flow/scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from optparse import Values
from pathlib import Path
import re
import sys
import tomli
from typing import Generator, Union

Expand Down Expand Up @@ -663,6 +664,13 @@ def get_option_parser() -> COP:
metavar="CODE",
choices=tuple([f'S{i["index"]:03d}' for i in STYLE_CHECKS.values()])
)
parser.add_option(
'--error-on-issues', '-e',
help='Return an error code if any issues are raised.',
action='store_true',
default=False,
dest='error'
)

return parser

Expand Down Expand Up @@ -759,6 +767,10 @@ def main(parser: COP, options: 'Values', target=None) -> None:

print(msg)

# Exit with an error code if there were warnings if requested
if options.error and count > 0:
sys.exit(1)


# NOTE: use += so that this works with __import__
# (docstring needed for `cylc help all` output)
Expand Down

0 comments on commit 8c7a2ec

Please sign in to comment.