diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1cf0bbc --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +.PHONY: clean-pyc + +default: test + +clean-pyc: + @find . -iname '*.py[co]' -delete + @find . -iname '__pycache__' -delete + +clean-dist: + @rm -rf dist/ + @rm -rf build/ + @rm -rf *.egg-info + +clean: clean-pyc clean-dist + +test: + pytest -vvv + +dist: clean + python3 setup.py sdist + python3 setup.py bdist_wheel + +version: dist + python3 setup.py --version diff --git a/README.md b/README.md index 5204763..62545d9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,41 @@ -# python3_CLI_boilerplate -A quick boilerplate for CLI apps/scripts in Python3 +# Awesome Python CLI Boilerplate + +A quick boilerplate when creating a new CLI apps/scripts in Python3. + +### Install + +Create and source a virtual environment: + +``` +virtualenv venv +source venv/bin/activate +``` + +Install dependencies: + +``` +pip3 install -r requirements.txt +``` + +Install package: + +``` +pip install . +``` + +Test your install with: + +``` +yourapp --help +``` + + +--- + +### Development + +Create a virtual environment and install the package with an editable option: + +``` +pip install --editable . +``` diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..23ba3e9 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +norecursedirs = venv* .* +addopts = + -r fEsxXw + -vvv diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ab0c2dc --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Click==7.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..3bbbfce --- /dev/null +++ b/setup.py @@ -0,0 +1,16 @@ +from setuptools import setup, find_packages + +setup( + name='yourapp', + version='0.0.1', + packages=find_packages(), + include_package_data=True, + author='Mia von Steinkirch', + install_requires=[ + 'Click', + ], + entry_points=''' + [console_scripts] + yourapp=yourapp.yourapp:main + ''', +) \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..5f7ce86 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/env python3 \ No newline at end of file diff --git a/yourapp/__init__.py b/yourapp/__init__.py new file mode 100644 index 0000000..5f7ce86 --- /dev/null +++ b/yourapp/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/env python3 \ No newline at end of file diff --git a/yourapp/yourapp.py b/yourapp/yourapp.py new file mode 100644 index 0000000..7c45b68 --- /dev/null +++ b/yourapp/yourapp.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import os +import re +import click + + +@click.command() + +@click.option('-s', + '--source', + default='dev', + nargs=1, + show_default=True, + help='Some source string.') + +@click.option('-t', + '--target', + default='staging', + nargs=1, + show_default=True, + help='Some target string.') + +@click.option('-p', + '--services', + required=True) + + +def main(source, target, services): + print(source, target, services) + + +if __name__ == "__main__": + main(source, target, services)