Skip to content

Commit

Permalink
Drop the click dependency
Browse files Browse the repository at this point in the history
This reduces the number of external dependencies and relies more on
Python's standard library.

It drops the --no-push option since argparse doesn't support having a
--option / --no-option. That's also the default and this makes it
clearer to the user what the default is.

The help text's formatting is slightly different. Mostly visible are
that the description and epilog are no longer indented.
  • Loading branch information
ekohl committed Sep 23, 2021
1 parent 01f74a3 commit 484faf1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 40 deletions.
43 changes: 20 additions & 23 deletions PyGitUp/gitup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
###############################################################################

# Python libs
import argparse
import codecs
import errno
import sys
Expand All @@ -29,7 +30,6 @@
else: # pragma: no cover
NO_DISTRIBUTE = False

import click
import colorama
from git import Repo, GitCmdObjectDB
from termcolor import colored
Expand Down Expand Up @@ -534,46 +534,43 @@ def print_error(self, error):
'''


@click.command(epilog=EPILOG)
@click.option('-V', '--version', is_flag=True,
help='Show version (and if there is a newer version).')
@click.option('-q', '--quiet', is_flag=True,
help='Be quiet, only print error messages.')
@click.option('--no-fetch', '--no-f', is_flag=True,
help='Don\'t try to fetch from origin.')
@click.option('-p', '--push/--no-push', default=None,
help='Push the changes after pulling successfully.')
@click.help_option('-h', '--help')
def run(version, quiet, no_fetch, push, **kwargs): # pragma: no cover
def run(): # pragma: no cover
"""
A nicer `git pull`.
"""
if version:

parser = argparse.ArgumentParser(description="A nicer `git pull`.", epilog=EPILOG)
parser.add_argument('-V', '--version', action='store_true',
help='Show version (and if there is a newer version).')
parser.add_argument('-q', '--quiet', action='store_true',
help='Be quiet, only print error messages.')
parser.add_argument('--no-fetch', '--no-f', dest='fetch', action='store_false',
help='Don\'t try to fetch from origin.')
parser.add_argument('-p', '--push', action='store_true',
help='Push the changes after pulling successfully.')

args = parser.parse_args()

if args.version:
if NO_DISTRIBUTE:
print(colored('Please install \'git-up\' via pip in order to '
'get version information.', 'yellow'))
else:
GitUp(sparse=True).version_info()
return

if quiet:
if args.quiet:
sys.stdout = StringIO()

try:
gitup = GitUp()

if push is not None:
gitup.settings['push.auto'] = push

# if arguments['--no-fetch'] or arguments['--no-f']:
if no_fetch:
gitup.should_fetch = False

gitup.settings['push.auto'] = args.push
gitup.should_fetch = args.fetch
except GitError:
sys.exit(1) # Error in constructor
else:
gitup.run()


if __name__ == '__main__': # pragma: no cover
run(help_option_names=['-h'])
run()
16 changes: 0 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ classifiers = [
[tool.poetry.dependencies]
python = "^3.7"
GitPython = "^3.0.0"
click = "^8.0"
colorama = "^0.4.0"
termcolor = "^1.1.0"

Expand Down

0 comments on commit 484faf1

Please sign in to comment.