mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
Refactored how entry points work.
This commit is contained in:
parent
5db7f2d807
commit
45741545dc
8 changed files with 71 additions and 42 deletions
16
pre_commit_hooks/util.py
Normal file
16
pre_commit_hooks/util.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
import functools
|
||||
import sys
|
||||
|
||||
|
||||
def entry(func):
|
||||
"""Allows a function that has `argv` as an argument to be used as a
|
||||
commandline entry. This will make the function callable using either
|
||||
explicitly passed argv or defaulting to sys.argv[1:]
|
||||
"""
|
||||
@functools.wraps(func)
|
||||
def wrapper(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
return func(argv)
|
||||
return wrapper
|
||||
Loading…
Add table
Add a link
Reference in a new issue