Aw, yeah, starting to look like a grown-up now.

This commit is contained in:
Elf M. Sternberg 2016-09-26 16:00:22 -07:00
parent c89743dd23
commit 60e3e8d328
2 changed files with 39 additions and 36 deletions

39
bin/git-lint Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env python
import git_lint
def main(*args):
if git_lint.git_base is None:
sys.exit(_('A git repository was not found.'))
(cmdline, filenames, excluded_commands) = git_lint.make_rational_options(git_lint.OPTIONS_LIST, args)
if len(excluded_commands) > 0:
print(_('These command line options were ignored due to option precedence.'))
for exc in excluded_commands:
print("\t{}".format(exc))
try:
config = git_lint.get_config(cmdline, git_lint.git_base)
if 'help' in cmdline:
git_lint.print_help(OPTIONS_LIST, NAME)
return 0
if 'version' in cmdline:
git_lint.print_version(NAME, VERSION)
return 0
if 'linters' in cmdline:
git_lint.print_linters(config)
return 0
return git_lint.run_gitlint(cmdline, config, filenames)
except getopt.GetoptError as err:
git_lint.print_help(OPTIONS_LIST)
return 1
if __name__ == '__main__':
import sys
sys.exit(main(*sys.argv))

View File

@ -641,39 +641,3 @@ def print_version(name, version):
print('{} {} Copyright (c) 2009, 2016 Kennth M. "Elf" Sternberg'.format(name, version))
def main(*args):
if git_base is None:
sys.exit(_('A git repository was not found.'))
(cmdline, filenames, excluded_commands) = make_rational_options(OPTIONS_LIST, args)
if len(excluded_commands) > 0:
print(_('These command line options were ignored due to option precedence.'))
for exc in excluded_commands:
print("\t{}".format(exc))
try:
config = get_config(cmdline, git_base)
if 'help' in cmdline:
print_help(OPTIONS_LIST, NAME)
return 0
if 'version' in cmdline:
print_version(NAME, VERSION)
return 0
if 'linters' in cmdline:
print_linters(config)
return 0
return run_gitlint(cmdline, config, filenames)
except getopt.GetoptError as err:
print_help(OPTIONS_LIST)
return 1
if __name__ == '__main__':
import sys
sys.exit(main(*sys.argv))