mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-30 18:26:53 +00:00
Add optional --quiet arg to trailing_whitespace
Allows `trailing_whitespace` to simply run without creating a failure. example: ``` repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: - id: trailing-whitespace args: [--quiet] ```
This commit is contained in:
parent
bb4e628bb4
commit
7441ea2676
1 changed files with 10 additions and 1 deletions
|
|
@ -65,6 +65,15 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|||
'Defaults to all whitespace characters.'
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--quiet','-q',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=(
|
||||
'Fix whitespace without failing. ',
|
||||
'default: %(default)s'
|
||||
),
|
||||
)
|
||||
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
|
|
@ -93,7 +102,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|||
for filename in args.filenames:
|
||||
_, extension = os.path.splitext(filename.lower())
|
||||
md = all_markdown or extension in md_exts
|
||||
if _fix_file(filename, md, chars):
|
||||
if _fix_file(filename, md, chars) and not args.quiet:
|
||||
print(f'Fixing {filename}')
|
||||
return_code = 1
|
||||
return return_code
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue