mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Merge 88ff7b12f2 into 2f8b625855
This commit is contained in:
commit
270652fff8
4 changed files with 64 additions and 0 deletions
33
pre_commit_hooks/print_message.py
Normal file
33
pre_commit_hooks/print_message.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
default_message = 'You failed to provide a message to the `print_message` pre-commit hook via the -m or --message arg'
|
||||
|
||||
|
||||
def main(argv=[]):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'-m',
|
||||
'--message',
|
||||
dest='message',
|
||||
default=default_message,
|
||||
help='the message to display when this pre-commit hook is triggered',
|
||||
)
|
||||
parser.add_argument(
|
||||
'-f',
|
||||
'--fail',
|
||||
dest='outcome',
|
||||
action='store_const',
|
||||
const=1,
|
||||
default=0,
|
||||
help='use this flag to make the pre-commit hook fail if it is triggered',
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
print(args.message)
|
||||
return args.outcome
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue