Browser and install GUI for cookiecutter templates

⌈⌋ ⎇ branch:  cookiedough


Artifact [ee7111ba97]

Artifact ee7111ba97ab8673580990a06aeb1954d3ece9035c9012877395edf85220a923:

  • File manpage/cookiecutter.md — part of check-in [0446dd68e4] at 2021-03-23 15:10:12 on branch trunk — Updated help pages, and update method (user: mario size: 7105)

% cookiecutter(1) cookiedough/cookiecutter Version 1.7

% cookiecutter project (audreyfeldroy, freakboy3742, stevepiercy, terryjbates, pokoli, saxix, hackebrot, pfmoore, macrotim, kmike, foobacca, luzfcb, ivanovmg), (c) BSDL-3

NAME

cookiecutter — expands project templates

SYNOPSIS

cookiecutter [http://git-repo/]

cookiecutter [OPTIONS] TEMPLATE [EXTRA_CONTEXT...]

DESCRIPTION

A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python package project template.

OPTIONS

The TEMPLATE parameter can either be a remote repository http://git.example.com/co.git (only Git/Mercurial supported), a local checkout ./local-template/, the name of any previously-ran-template, and a local or remote zip file http://fsl.example.com/repo.zip even.

-V, --version : Show the version and exit.

--no-input : Do not prompt for parameters and only use cookiecutter.json file content

-c, --checkout TRUNK : branch, tag or commit to checkout after git clone

--directory DIR : Directory within repo that holds cookiecutter.json file for advanced repositories with multi templates in it

-v, --verbose : Print debug information

--replay : Do not prompt for parameters and only use information entered previously

-f, --overwrite-if-exists : Overwrite the contents of the output directory if it already exists

-s, --skip-if-file-exists : Skip the files in the corresponding directories if they already exist

-o, --output-dir PATH : Where to output the generated project dir into

--config-file FN : User configuration file

--default-config : Do not load a config file. Use the defaults instead

--debug-file LOG : File to be used as a stream for DEBUG logging

USAGE

Grab a Cookiecutter template

First, clone a Cookiecutter project template::

$ git clone git@github.com:audreyr/cookiecutter-pypackage.git

Make your changes

Modify the variables defined in cookiecutter.json.

Open up the skeleton project. If you need to change it around a bit, do so.

You probably also want to create a repo, name it differently, and push it as your own new Cookiecutter project template, for handy future use.

Generate your project

Then generate your project from the project template::

$ cookiecutter cookiecutter-pypackage/

The only argument is the input directory. (The output directory is generated by rendering that, and it can't be the same as the input directory.)

.. note:: see :ref:command_line_options for extra command line arguments

Try it out!

Works directly with git and hg (mercurial) repos too

To create a project from the cookiecutter-pypackage.git repo template::

$ cookiecutter gh:audreyr/cookiecutter-pypackage

Cookiecutter knows abbreviations for Github (gh), Bitbucket (bb), and GitLab (gl) projects, but you can also give it the full URL to any repository::

$ cookiecutter https://github.com/audreyr/cookiecutter-pypackage.git
$ cookiecutter git+ssh://git@github.com/audreyr/cookiecutter-pypackage.git
$ cookiecutter hg+ssh://hg@bitbucket.org/audreyr/cookiecutter-pypackage

You will be prompted to enter a bunch of project config values. (These are defined in the project's cookiecutter.json.)

Then, Cookiecutter will generate a project from the template, using the values that you entered. It will be placed in your current directory.

And if you want to specify a branch you can do that with::

$ cookiecutter https://github.com/audreyr/cookiecutter-pypackage.git --checkout develop

Works with private repos

If you want to work with repos that are not hosted in github or bitbucket you can indicate explicitly the type of repo that you want to use prepending hg+ or git+ to repo url::

$ cookiecutter hg+https://example.com/repo

In addition, one can provide a path to the cookiecutter stored on a local server::

$ cookiecutter file://server/folder/project.git

Works with Zip files

You can also distribute cookiecutter templates as Zip files. To use a Zip file template, point cookiecutter at a Zip file on your local machine::

$ cookiecutter /path/to/template.zip

Or, if the Zip file is online::

$ cookiecutter https://example.com/path/to/template.zip

If the template has already been downloaded, or a template with the same name has already been downloaded, you will be prompted to delete the existing template before proceeding.

The Zip file contents should be the same as a git/hg repository for a template - that is, the zipfile should unpack into a top level directory that contains the name of the template. The name of the zipfile doesn't have to match the name of the template - for example, you can label a zipfile with a version number, but omit the version number from the directory inside the Zip file.

If you want to see an example Zipfile, find any Cookiecutter repository on Github and download that repository as a zip file - Github repository downloads are in a valid format for Cookiecutter.

Password-protected Zip files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If your repository Zip file is password protected, Cookiecutter will prompt you for that password whenever the template is used.

Alternatively, if you want to use a password-protected Zip file in an automated environment, you can export the COOKIECUTTER_REPO_PASSWORD environment variable; the value of that environment variable will be used whenever a password is required.

Keeping your cookiecutters organized

As of the Cookiecutter 0.7.0 release:

  • Whenever you generate a project with a cookiecutter, the resulting project is output to your current directory.

  • Your cloned cookiecutters are stored by default in your ~/.cookiecutters/ directory (or Windows equivalent). The location is configurable: see :doc:advanced/user_config for details.

Pre-0.7.0, this is how it worked:

  • Whenever you generate a project with a cookiecutter, the resulting project is output to your current directory.

  • Cloned cookiecutters were not saved locally.

DOCS

  • Documentation: https://cookiecutter.readthedocs.io
  • GitHub: https://github.com/cookiecutter/cookiecutter
  • PyPI: https://pypi.python.org/pypi/cookiecutter

FILES

~/.cookiecutterrc : config store

~/.cookiecutters/ : cache dir

These default paths are not XDG-compliant (https://github.com/cookiecutter/cookiecutter/issues/104). cookiedough(1) always overrides those settings, but also provides a patch to permanently fix the builtin defaults to ~/.config/cookiecutter/config and ~/.cache/cookiecutters/ respectively.

ENV

COOKIECUTTER_CONFIG : Location of YAML file to use in place of ~/.cookiecutterrc.
: Can also be specified per --config-file option.

SEE ALSO

cookiedough(1), python3(1)