mirror of
https://github.com/pre-commit/pre-commit.git
synced 2025-12-31 22:10:04 -06:00
Fix entry_points
This commit is contained in:
@@ -57,7 +57,6 @@ def check_is_valid_manifest(file_contents):
|
||||
)
|
||||
|
||||
|
||||
|
||||
def run(argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
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)
|
||||
|
||||
if args.install:
|
||||
install()
|
||||
return install()
|
||||
elif args.uninstall:
|
||||
uninstall()
|
||||
return uninstall()
|
||||
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',
|
||||
'simplejson',
|
||||
],
|
||||
scripts=[
|
||||
'scripts/pre-commit.py',
|
||||
'scripts/validate-manifest.py',
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'pre-commit = pre_commit.entry_points:pre_commit_func',
|
||||
'validate-manifest = pre_commit.entry_points:validate_manifest_func',
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user