跳转到主要内容

cookiecutter的友好界面封装

项目描述

pieceofcake - 一个友好的cookiecutter封装

这是一个围绕cookiecutter工具的封装,它提供了一种更用户友好的提问方式。

使用cookiecutter时,用户不会看到任何问题,只会显示要设置的参数名称

% cookiecutter gh:astrofrog/fake-template
package_name [example]: test-package
include_example_code [n]: y

使用pieceofcake时,用户会看到一系列详细的提问,这提供了关于每个参数含义/影响的更多上下文

% cookiecutter gh:astrofrog/fake-template final-package

Welcome to the pieceofcake, a user-friendly cookiecutter wrapper!

This script will now ask you a series of questions to help you set up
your package.

What is the name of your package? This is the name that will appear on
PyPI and which users will use when installing the package with e.g.
pip or conda.
> Package name [example]: test-package

Should example code be included? This will consist of sample Python
and Cython files in the package, demonstrating how to create different
sub-modules and importing between them.
> Include example code? [n]: y

Running cookiecutter...

You should now be all set! Your generated package is in final-package

安装

要安装,请运行

pip install pieceofcake

使用

要使用pieceofcake

pieceofcake template output_directory

其中template遵循与cookiecutter相同的语法,可以是本地目录的路径,或者例如gh:astrofrog/fake-template,以使用GitHub存储库。

请注意,pieceofcake将与所有cookiecutter模板一起工作,但如果要在下面所述的模板创建者中包含cookiecutter.json文件中的_parameters键,则只会显示友好问题。

对于模板创建者

为了为每个参数定义问题,在您的cookiecutter.json文件中添加一个新的_parameters键,然后它应该包含每个参数的字典

"_parameters": {
    "package_name": {
        "default_value": "test-package",
        "prompt": "Package name",
        "help": "What is the name of your package? This is the name that will appear on PyPI and which users will use when installing the package with e.g. pip or conda."
    },
    "include_example_code": {
        "prompt": "Include example code?",
        "help": "Should example code be included? This will consist of sample Python and Cython files in the package, demonstrating how to create different sub-modules and importing between them."
    }
}

default_valueprompthelp键都是可选的 - 如果未定义default_value,则从主cookiecutter部分获取默认值。如果没有包括prompt,则将其设置为参数名称,如果没有包括help,则不会显示帮助/问题。

这种方法受到了cookiecutter/cookiecutter#794的启发

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。

源代码分发

pieceofcake-0.1a2.tar.gz (5.7 kB 查看哈希值)

上传时间 源代码

构建分发

pieceofcake-0.1a2-py3-none-any.whl (5.7 kB 查看哈希值)

上传时间 Python 3

由以下机构支持