mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-20 01:24:42 +04:00
Fix entry_points
This commit is contained in:
parent
eb592046e3
commit
18976b501d
6 changed files with 32 additions and 24 deletions
|
|
@ -57,7 +57,6 @@ def check_is_valid_manifest(file_contents):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run(argv):
|
def run(argv):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
|
||||||
23
pre_commit/entry_points.py
Normal file
23
pre_commit/entry_points.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
|
import pre_commit.clientlib.validate_manifest
|
||||||
|
import pre_commit.run
|
||||||
|
|
||||||
|
|
||||||
|
def make_entry_point(entry_point_func):
|
||||||
|
"""Decorator which turns a function which takes sys.argv[1:] and returns
|
||||||
|
an integer into an argumentless function which returns an integer.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
entry_point_func - A function which takes an array representing argv
|
||||||
|
"""
|
||||||
|
@functools.wraps(entry_point_func)
|
||||||
|
def func():
|
||||||
|
import sys
|
||||||
|
return entry_point_func(sys.argv[1:])
|
||||||
|
return func
|
||||||
|
|
||||||
|
|
||||||
|
pre_commit_func = make_entry_point(pre_commit.run.run)
|
||||||
|
validate_manifest_func = make_entry_point(pre_commit.clientlib.validate_manifest.run)
|
||||||
|
|
@ -35,8 +35,8 @@ def run(argv):
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
if args.install:
|
if args.install:
|
||||||
install()
|
return install()
|
||||||
elif args.uninstall:
|
elif args.uninstall:
|
||||||
uninstall()
|
return uninstall()
|
||||||
else:
|
else:
|
||||||
run_hooks(args)
|
return run_hooks(args)
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from pre_commit.run import run
|
|
||||||
|
|
||||||
sys.exit(run(sys.argv[1:]))
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from pre_commit.clientlib.validate_manifest import run
|
|
||||||
|
|
||||||
sys.exit(run(sys.argv[1:]))
|
|
||||||
10
setup.py
10
setup.py
|
|
@ -12,8 +12,10 @@ setup(
|
||||||
'pyyaml',
|
'pyyaml',
|
||||||
'simplejson',
|
'simplejson',
|
||||||
],
|
],
|
||||||
scripts=[
|
entry_points={
|
||||||
'scripts/pre-commit.py',
|
'console_scripts': [
|
||||||
'scripts/validate-manifest.py',
|
'pre-commit = pre_commit.entry_points:pre_commit_func',
|
||||||
],
|
'validate-manifest = pre_commit.entry_points:validate_manifest_func',
|
||||||
|
],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue