├── README.rst ├── cookiecutter.json └── {{cookiecutter.repo_name}} ├── .bumpversion.cfg ├── .circleci └── config.yml ├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── MANIFEST.in ├── README.rst ├── setup.cfg ├── setup.py └── {{cookiecutter.package_name}} ├── __init__.py └── cli.py /README.rst: -------------------------------------------------------------------------------- 1 | Cookiecutter Python CLI 2 | ======================= 3 | 4 | To create a new project run the following commands. This assumes that you have 5 | `virtualenvwrapper` installed. 6 | 7 | .. code-block:: 8 | 9 | $ mkvirtualenv my-project 10 | $ pip install cookiecutter 11 | $ cookiecutter gh:elbaschid/cc-python-cli 12 | -------------------------------------------------------------------------------- /cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "repo_name": "my-python-cli", 3 | "package_name": "package_name", 4 | "description": "", 5 | "cli_name": "cli_name", 6 | "github_user": "elbaschid", 7 | "author_name": "Sebastian Vetter", 8 | "author_email": "seb@roadsi.de", 9 | "year": "2017" 10 | } 11 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 00.0.0.0 3 | serialize = {now:%y.%-m.%-d}.{release} 4 | parse = \d{2}.\d{1,2}.\d{1,2}.(?P\d+) 5 | commit = True 6 | tag = True 7 | tag_name = v{new_version} 8 | 9 | [bumpversion:file:setup.py] 10 | [bumpversion:file:{{cookiecutter.package_name}}.__init__.py] 11 | 12 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/.circleci/config.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | python: 3 | version: 3.6.1 4 | services: 5 | - redis 6 | - postgresql 7 | 8 | dependencies: 9 | pre: 10 | 11 | test: 12 | pre: 13 | 14 | 15 | # Python CircleCI 2.0 configuration file 16 | # 17 | # Check https://circleci.com/docs/2.0/language-python/ for more details 18 | # 19 | version: 2 20 | jobs: 21 | build: 22 | docker: 23 | - image: circleci/python:3.6.1 24 | 25 | - image: circleci/postgres:9.6-alpine 26 | environment: 27 | POSTGRES_USER: ubuntu 28 | POSTGRES_DB: circle_test 29 | POSTGRES_PASSWORD: "" 30 | 31 | environment: 32 | DATABASE_URL: postgresql://ubuntu@127.0.0.1:5432/circle_test 33 | REDIS_URL: redis://127.0.0.1:6379/0 34 | DJANGO_SECRET_KEY: secret key just for testing 35 | 36 | working_directory: ~/repo 37 | 38 | steps: 39 | - checkout 40 | 41 | {% raw %} 42 | # Download and cache dependencies 43 | - restore_cache: 44 | keys: 45 | - v1-dependencies-{{ checksum "setup.py" }} 46 | # fallback to using the latest cache if no exact match is found 47 | - v1-dependencies- 48 | 49 | - run: 50 | name: install dependencies 51 | command: | 52 | python3 -m venv venv 53 | . venv/bin/activate 54 | pip install -e ".[dev]" 55 | 56 | - save_cache: 57 | paths: 58 | - ./venv 59 | key: v1-dependencies-{{ checksum "setup.py" }} 60 | {% endraw %} 61 | 62 | # run tests! 63 | - run: 64 | name: run tests 65 | command: | 66 | . venv/bin/activate 67 | py.test --cov {{cookiecutter.package_name}} 68 | flake8 {{cookiecutter.package_name}} 69 | black --check {{cookiecutter.package_name}} 70 | 71 | - store_artifacts: 72 | path: test-reports 73 | destination: test-reports 74 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/.gitignore: -------------------------------------------------------------------------------- 1 | *.sw[a-z] 2 | *.py[cox] 3 | *.sqlite 4 | 5 | .env* 6 | .coverage 7 | 8 | .cache/ 9 | .tox/ 10 | *.egg-info/ 11 | 12 | htmlcov/ 13 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/ambv/black 3 | rev: stable 4 | hooks: 5 | - id: black 6 | args: [--line-length=88, --safe] 7 | python_version: python3.6 8 | - repo: local 9 | hooks: 10 | - id: flake8 11 | name: flake8 12 | language: system 13 | entry: flake8 --config=setup.cfg 14 | files: ({{cookiecutter.package_name}}|tests)/.*\.py$ 15 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) {{cookiecutter.year}} {{cookiecutter.author_name}} 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst LICENSE 2 | prune *.pyc 3 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/README.rst: -------------------------------------------------------------------------------- 1 | {{cookiecutter.repo_name}} 2 | ############################# 3 | 4 | 5 | .. image:: https://travis-ci.org/{{cookiecutter.github_user}}/{{cookiecutter.repo_name}}.svg?branch=master 6 | :target: https://travis-ci.org/{{cookiecutter.github_user}}/{{cookiecutter.repo_name}} 7 | 8 | 9 | License 10 | ------- 11 | 12 | This code is licensed under the `MIT License`_. 13 | 14 | .. _`MIT License`: https://github.com/{{cookiecutter.github_user}}/{{cookiecutter.repo_name}}/blob/master/LICENSE 15 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | 4 | [flake8] 5 | ignore = F401 6 | max_line_length = 100 7 | exclude = .git,__pycache__,venv 8 | 9 | [tool:pytest] 10 | norecursedirs = .* build dist docs docker 11 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/setup.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from setuptools import setup, find_packages 4 | 5 | requires = ["click"] 6 | tests_requires = ["pytest", "pytest-cache", "pytest-cov"] 7 | lint_requires = ["flake8", "black"] 8 | dev_requires = ["bumpversion"] + requires + tests_requires + lint_requires 9 | 10 | 11 | setup( 12 | name="{{cookiecutter.repo_name}}", 13 | version="00.0.0.0", 14 | description="{{cookiecutter.description}}", 15 | long_description="\n\n".join([open("README.rst").read()]), 16 | license="MIT", 17 | author="{{cookiecutter.author_name}}", 18 | author_email="{{cookiecutter.author_email}}", 19 | url="https://{{cookiecutter.repo_name}}.readthedocs.org", 20 | packages=find_packages(), 21 | install_requires=requires, 22 | entry_points={ 23 | "console_scripts": [ 24 | "{{cookiecutter.cli_name}} = {{cookiecutter.package_name}}.cli:main" 25 | ] 26 | }, 27 | classifiers=[ 28 | "License :: OSI Approved :: MIT License", 29 | "Programming Language :: Python", 30 | "Programming Language :: Python :: 3", 31 | "Programming Language :: Python :: Implementation :: CPython", 32 | ], 33 | extras_require={"test": tests_requires, "dev": dev_requires, "lint": lint_requires}, 34 | ) 35 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "00.0.0.0" 2 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/cli.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | 4 | @click.command() 5 | def main(): 6 | print("I am {{cookiecutter.cli_name}}") 7 | --------------------------------------------------------------------------------