Add a -q option to be silent on success
Change-Id: I5cd7f72694d525420a46e5ec2aca1b394bbf7b90
This commit is contained in:
parent
08be40a220
commit
bcdaf5f788
@ -73,6 +73,7 @@ Command line usage
|
|||||||
-e extension, --extension extension
|
-e extension, --extension extension
|
||||||
check file extensions of the given type (default:
|
check file extensions of the given type (default:
|
||||||
.rst, .txt).
|
.rst, .txt).
|
||||||
|
-q, --quiet only print violations
|
||||||
-v, --verbose run in verbose mode.
|
-v, --verbose run in verbose mode.
|
||||||
--version show the version and exit.
|
--version show the version and exit.
|
||||||
|
|
||||||
|
28
doc8/main.py
28
doc8/main.py
@ -176,7 +176,8 @@ def setup_logging(verbose):
|
|||||||
|
|
||||||
|
|
||||||
def scan(cfg):
|
def scan(cfg):
|
||||||
print("Scanning...")
|
if not cfg.get('quiet'):
|
||||||
|
print("Scanning...")
|
||||||
files = collections.deque()
|
files = collections.deque()
|
||||||
ignored_paths = cfg.get('ignore_path', [])
|
ignored_paths = cfg.get('ignore_path', [])
|
||||||
files_ignored = 0
|
files_ignored = 0
|
||||||
@ -200,7 +201,8 @@ def scan(cfg):
|
|||||||
|
|
||||||
|
|
||||||
def validate(cfg, files):
|
def validate(cfg, files):
|
||||||
print("Validating...")
|
if not cfg.get('quiet'):
|
||||||
|
print("Validating...")
|
||||||
error_counts = {}
|
error_counts = {}
|
||||||
ignoreables = frozenset(cfg.get('ignore', []))
|
ignoreables = frozenset(cfg.get('ignore', []))
|
||||||
ignore_targeted = cfg.get('ignore_path_errors', {})
|
ignore_targeted = cfg.get('ignore_path_errors', {})
|
||||||
@ -325,6 +327,8 @@ def main():
|
|||||||
help="check file extensions of the given type"
|
help="check file extensions of the given type"
|
||||||
" (default: %s)." % ", ".join(FILE_PATTERNS),
|
" (default: %s)." % ", ".join(FILE_PATTERNS),
|
||||||
default=list(FILE_PATTERNS))
|
default=list(FILE_PATTERNS))
|
||||||
|
parser.add_argument("-q", "--quiet", action='store_true',
|
||||||
|
help="only print violations", default=False)
|
||||||
parser.add_argument("-v", "--verbose", dest="verbose", action='store_true',
|
parser.add_argument("-v", "--verbose", dest="verbose", action='store_true',
|
||||||
help="run in verbose mode.", default=False)
|
help="run in verbose mode.", default=False)
|
||||||
parser.add_argument("--version", dest="version", action='store_true',
|
parser.add_argument("--version", dest="version", action='store_true',
|
||||||
@ -358,15 +362,17 @@ def main():
|
|||||||
error_counts = validate(args, files)
|
error_counts = validate(args, files)
|
||||||
total_errors = sum(six.itervalues(error_counts))
|
total_errors = sum(six.itervalues(error_counts))
|
||||||
|
|
||||||
print("=" * 8)
|
if not args.get('quiet'):
|
||||||
print("Total files scanned = %s" % (files_selected))
|
print("=" * 8)
|
||||||
print("Total files ignored = %s" % (files_ignored))
|
print("Total files scanned = %s" % (files_selected))
|
||||||
print("Total accumulated errors = %s" % (total_errors))
|
print("Total files ignored = %s" % (files_ignored))
|
||||||
if error_counts:
|
print("Total accumulated errors = %s" % (total_errors))
|
||||||
print("Detailed error counts:")
|
if error_counts:
|
||||||
for check_name in sorted(six.iterkeys(error_counts)):
|
print("Detailed error counts:")
|
||||||
check_errors = error_counts[check_name]
|
for check_name in sorted(six.iterkeys(error_counts)):
|
||||||
print(" - %s = %s" % (check_name, check_errors))
|
check_errors = error_counts[check_name]
|
||||||
|
print(" - %s = %s" % (check_name, check_errors))
|
||||||
|
|
||||||
if total_errors:
|
if total_errors:
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user