diff --git a/.gitignore b/.gitignore index fe211142..831f634e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build dist *.egg-info +*.iml diff --git a/pre_commit/run.py b/pre_commit/run.py new file mode 100644 index 00000000..c281ff72 --- /dev/null +++ b/pre_commit/run.py @@ -0,0 +1,42 @@ + +import argparse + + +def install(): + """Install the pre-commit hook.""" + raise NotImplementedError + + +def uninstall(): + """Uninstall the pre-commit hook.""" + raise NotImplementedError + + +def run_hooks(arguments): + """Actually run the hooks.""" + raise NotImplementedError + + +def run(argv): + parser = argparse.ArgumentParser() + + group = parser.add_mutually_exclusive_group(required=False) + group.add_argument( + '-i', '--install', + action='store_true', + help='Install the pre-commit script.', + ) + group.add_argument( + '-u', '--uninstall', + action='store_true', + help='Uninstall the pre-commit script.', + ) + + args = parser.parse_args(argv) + + if args.install: + install() + elif args.uninstall: + uninstall() + else: + run_hooks(args) \ No newline at end of file diff --git a/scripts/pre-commit.py b/scripts/pre-commit.py new file mode 100755 index 00000000..063ad9c2 --- /dev/null +++ b/scripts/pre-commit.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +if __name__ == '__main__': + import sys + + from pre_commit.run import run + + sys.exit(run(sys.argv[1:])) \ No newline at end of file diff --git a/setup.py b/setup.py index afb1d1da..24ada47a 100644 --- a/setup.py +++ b/setup.py @@ -9,4 +9,7 @@ setup( 'argparse', 'simplejson', ], + scripts=[ + 'scripts/pre-commit.py', + ], )