From 35e92c96b600d6a3b6ad10324ecdcfd9d8039577 Mon Sep 17 00:00:00 2001 From: SaladRaider Date: Sat, 27 May 2017 10:38:36 -0700 Subject: [PATCH] Add starter code from cookiecutter --- .gitignore | 10 +++++++++ README.md | 22 ++++++++++++++++++- gitautosync/__init__.py | 0 gitautosync/cli.py | 10 +++++++++ setup.cfg | 2 ++ setup.py | 48 +++++++++++++++++++++++++++++++++++++++++ tests/__init__.py | 1 + tests/test_cli.py | 29 +++++++++++++++++++++++++ tox.ini | 15 +++++++++++++ 9 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 gitautosync/__init__.py create mode 100644 gitautosync/cli.py create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/test_cli.py create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..63f96039 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.pyc + +dist/ +build/ +*.egg-info/ + +.tox/ +.coverage + +.DS_Store diff --git a/README.md b/README.md index 1bae5d37..9ebeffb9 100644 --- a/README.md +++ b/README.md @@ -1 +1,21 @@ -# gitautosync \ No newline at end of file +# gitautosync + +Synchronizes a github repository with a local repository. Automatically deals with conflicts and produces useful output to stdout. + + +# Installation + +If you don't use `pipsi`, you're missing out. +Here are [installation instructions](https://github.com/mitsuhiko/pipsi#readme). + +Simply run: + + $ pipsi install . + + +# Usage + +To use it: + + $ gitautosync --help + diff --git a/gitautosync/__init__.py b/gitautosync/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/gitautosync/cli.py b/gitautosync/cli.py new file mode 100644 index 00000000..31cc3552 --- /dev/null +++ b/gitautosync/cli.py @@ -0,0 +1,10 @@ +import click + + +@click.command() +@click.option('--as-cowboy', '-c', is_flag=True, help='Greet as a cowboy.') +@click.argument('name', default='world', required=False) +def main(name, as_cowboy): + """Synchronizes a github repository with a local repository. Automatically deals with conflicts and produces useful output to stdout.""" + greet = 'Howdy' if as_cowboy else 'Hello' + click.echo('{0}, {1}.'.format(greet, name)) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..5e409001 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..ac1a4df6 --- /dev/null +++ b/setup.py @@ -0,0 +1,48 @@ +""" +Synchronizes a github repository with a local repository. Automatically deals with conflicts and produces useful output to stdout. +""" +from setuptools import find_packages, setup + +dependencies = ['click'] + +setup( + name='gitautosync', + version='0.0.1', + url='https://github.com/SaladRaider/gitautosync', + license='BSD', + author='Peter Veerman', + author_email='peterkangveerman@gmail.com', + description='Synchronizes a github repository with a local repository. Automatically deals with conflicts and produces useful output to stdout.', + long_description=__doc__, + packages=find_packages(exclude=['tests']), + include_package_data=True, + zip_safe=False, + platforms='any', + install_requires=dependencies, + entry_points={ + 'console_scripts': [ + 'gitautosync = gitautosync.cli:main', + ], + }, + classifiers=[ + # As from http://pypi.python.org/pypi?%3Aaction=list_classifiers + # 'Development Status :: 1 - Planning', + # 'Development Status :: 2 - Pre-Alpha', + # 'Development Status :: 3 - Alpha', + 'Development Status :: 4 - Beta', + # 'Development Status :: 5 - Production/Stable', + # 'Development Status :: 6 - Mature', + # 'Development Status :: 7 - Inactive', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Operating System :: POSIX', + 'Operating System :: MacOS', + 'Operating System :: Unix', + 'Operating System :: Microsoft :: Windows', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + 'Topic :: Software Development :: Libraries :: Python Modules', + ] +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 00000000..e0ee52da --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,29 @@ +import pytest +from click.testing import CliRunner +from gitautosync import cli + + +@pytest.fixture +def runner(): + return CliRunner() + + +def test_cli(runner): + result = runner.invoke(cli.main) + assert result.exit_code == 0 + assert not result.exception + assert result.output.strip() == 'Hello, world.' + + +def test_cli_with_option(runner): + result = runner.invoke(cli.main, ['--as-cowboy']) + assert not result.exception + assert result.exit_code == 0 + assert result.output.strip() == 'Howdy, world.' + + +def test_cli_with_arg(runner): + result = runner.invoke(cli.main, ['Peter']) + assert result.exit_code == 0 + assert not result.exception + assert result.output.strip() == 'Hello, Peter.' diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..b943252c --- /dev/null +++ b/tox.ini @@ -0,0 +1,15 @@ +[tox] +envlist=py26, py27, py33, py34, pypy, flake8 + +[testenv] +commands=py.test --cov gitautosync {posargs} +deps= + pytest + pytest-cov + +[testenv:flake8] +basepython = python2.7 +deps = + flake8 +commands = + flake8 gitautosync tests --max-line-length=120