Cookiecutter: Support better prompts

Created on 18 Aug 2013  路  6Comments  路  Source: cookiecutter/cookiecutter

Maybe we could support an enhanced cookiecutter.json file, like:

    [
        {
            "full_name": "Audrey Roy",
            "prompt": "Your full name?"
        },
        {
            "email": "[email protected]",
            "prompt": "Your email address?"
        },
        {
            "github_username": "audreyr",
            "prompt": "Your username on github.com?"
        },
        {
            "project_name": "Python Boilerplate",
            "prompt": "Official name of your project, as used in your docs?"
        },
        {
            "repo_name": "boilerplate",
            "prompt": "Lowercase, spaceless, version of your repo name?",
            "help_text": "This should be a name that is importable as a Python package."
        },
        {
            "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.",
            "prompt": "A 1-liner description of your project?"
        },
        {
            "release_date": "2013-08-11",
            "prompt": "Date that you plan to release your project?"
        },
        {
            "year": "2013",
            "prompt": "What year would you like to use in the copyright text?"
        },
        {
            "version": "0.1.0",
            "prompt": "Version number to start at?",
            "help_text": "We recommend using semantic versioning and starting at 0.1.0. See semver.org."
        }
    ]
enhancement

Most helpful comment

I think a better format would be something like:

{
    "full_name": {
        "default": "Audrey Roy",
        "prompt": "Your full name?"
    },
    "email": "[email protected]",
    "repo_name": {
            "default": "boilerplate",
            "prompt": "Lowercase, spaceless, version of your repo name?",
            "help_text": "This should be a name that is importable as a Python package."
        }
}

Note the mixed format.

This has the advantage of being backwards compatible...you just check whether the value in the map is a string or a dict and go from there.

Or YAML config file support might obviate the need for this.

All 6 comments

Something like this would increase the usability of cc quite a lot. I read somewhere that YAML would also be supported for cc config now, is this so? JSON gets quite tedious as more and more information is included in the config.

I think a better format would be something like:

{
    "full_name": {
        "default": "Audrey Roy",
        "prompt": "Your full name?"
    },
    "email": "[email protected]",
    "repo_name": {
            "default": "boilerplate",
            "prompt": "Lowercase, spaceless, version of your repo name?",
            "help_text": "This should be a name that is importable as a Python package."
        }
}

Note the mixed format.

This has the advantage of being backwards compatible...you just check whether the value in the map is a string or a dict and go from there.

Or YAML config file support might obviate the need for this.

See additional discussion on config format in #10.

+1, I'd like to be able to specify human readable prompts with more detail. I think a format like this would also allow for more extensions:

  • validation of values
  • support for non-string data types (ex: booleans for flags)

(I also think YAML would might it easier to write, and yaml supports inline comments!)

:+1: (with khorn's format)

Closing this in favor of #848

Was this page helpful?
0 / 5 - 0 ratings