原文檔地址:https://cookiecutter.readthedocs.io/en/latest/html
本系列只介紹cookiecutter的基礎使用,並且會刪除與功能使用無關的部分。深度使用及瞭解更多詳情請請參考原文檔。前端
關於Cookiecutter的中文譯名,我不知作別人怎麼翻譯的,我將其翻譯爲餅乾製造機。本系列中將不對其做翻譯,直接使用英文原名。java
Cookiecutter 是一個經過項目模板建立項目的命令行工具。好比,經過Python Package模板來建立Python package項目。(經過Python代碼調用Cookiecutter的API能夠擴展爲自動化建立服務和帶有Web UI的服務程序)node
# 從cookiecutter-pypackage.git模板建立項目 # 你將會被提示輸入相應的值。 # 而後Cookiecutter將基於你的輸入在當前工做目錄中建立Python包 $ cookiecutter https://github.com/audreyr/cookiecutter-pypackage # 爲了簡潔起見,repos在GitHub上能夠只使用「gh」前綴 $ cookiecutter gh:audreyr/cookiecutter-pypackage
# 從本地在當前目錄建立項目 # cookiecutter-pypackage/ template $ cookiecutter cookiecutter-pypackage/
{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}.py
{ "full_name": "Tacey Wong", "email": "xinyong.wang@qq.com", "project_name": "Complexity", "repo_name": "complexity", "project_short_description": "使人耳目一新的簡單的靜態網站生成器.", "release_date": "2019-03-10", "year": "2019", "version": "0.0.1" }
cookiecutter.json
中鍵/key對應的值/value。cookiecutter.json
中的缺省值~/.cookiecutterrc
文件:default_context: full_name: "Tacey Wong" email: "xinyong.wang@qq.com" github_username: "taceywong" cookiecutters_dir: "~/.cookiecutters/"
~/.cookiecutters/
目錄下,若是特殊指定,會放置在cookiecutters_dir
對應的目錄下:# 克隆cookiecutter-pypackage $ cookiecutter gh:audreyr/cookiecutter-pypackage # 如今你能夠根據名字使用對應的模板 $ cookiecutter cookiecutter-pypackage
$ cookiecutter --no-input gh:msabramo/cookiecutter-supervisor program_name=foobar startsecs=10
如今在已經有不少開源的Cookiecutter 項目模板可供選擇。python
這些模板由cookiecutter官方團隊進行維護:jquery
社區驅動的各種Cookiecutter模板(非Cookiecutter官方維護)android
Pythonwebpack
impress.js
幻燈片)Python-Djangoios
Python-Pyramidgit
Cookiecutter (meta)
用於生成Cookiecutter項目模板的元模板。
Ansible
Git
C
C++
C#
Common Lisp
Elm
Golang
Java
JS
Kotlin
LaTeX/XeTeX
PHP
Sublime Text
Berkshelf-Vagrant
HTML
cookiecutter-tumblr-theme: 使用GruntJS做爲鏈接工具的Tumblr主題項目的cookiecutter模板。
Scala
cookiecutter-scala-spark: 用Scala編寫的Apache Spark應用程序的cookiecutter模板。
6502 Assembly
cookiecutter-atari2600: Atari2600項目的cookiecutter模板。
Data Science
Reproducible Science
數據驅動的Journalism
持續交付
其餘