Questions file format (scaffold.yml
)
The scaffold.yml
file describes the questions you wish the end-user to answer before generating a template.
Naming
By default, a file scaffold.yml
will be searched for when specifing a folder as the the project template.
Nevertheless, you are free to name the file as you wish and specifiy it directly on the command line.
Sections
questions
name: The name of the variable to export.
description:
Schema options:
type: Defaults to string, but can also be boolean.
default: Default value for the field. Jinja expressions are allowed, including a value that was read from an answers file.
nullable: Allow the answer to be an empty (eg: “”) value.
min_length: The provided answer must be longer than this many characters.
max_length: The provided answer must be shorter than this many characters.
allowed: List of values that are accepted.
hidden: Defaults to False. A hidden field will not be prompted to user. Supports jinja2 templating.
---
questions:
- name: "author"
description: "The author's name"
schema:
default: "John Doe"
nullable: true
- name: "project_name"
schema:
min_length: 1
- name: "project_short_description"
schema:
default: "Lorem ipsum sit dolor amet."
max_length: 120
nullable: true
- name: "project_slug"
schema:
default: "{{ scaffold.project_name | lower() | replace(' ', '-') | replace('-', '_') }}"
- name: "project_directory"
schema:
default: "{{ scaffold.project_name | lower() | replace(' ', '-') }}"
- name: "use_python"
schema:
type: boolean
default: true
- name: "has_package"
if: "{{ scaffold.use_python }}"
schema:
type: boolean
default: true
- name: "python_min_version"
if: "{{ scaffold.use_python }}"
schema:
default: "3.7"
allowed: [
"3.6",
"3.7",
"3.8",
"3.9",
]
- name: "creation_year"
schema:
default: "{{ scaffold.creation_year | d(year) }}"
hidden: True
jinja2
The jinja2
allows you to specify options to pass the the jinja2 templating parser. Options are passed as is.
For example:
---
jinja2:
lstrip_blocks: true
trim_blocks: true
Files
The files section allows you to add actions to be realised on files after templating. Such actions include, for example, deleting files or a folder if a specific feature was not asked for by user.
Actions:
remove: Delete file.
move: Move file from path to dest.
---
files:
- path: "LICENSE.MIT"
dest: "LICENSE"
if: "{{ scaffold.license == 'MIT' }}"
action: "move"
- path: [ "LICENSE", "LICENSE.MIT" ]
if: "{{ scaffold.license == 'none' }}"
action: "remove"
- path: "setup.py"
if: "{{ not (scaffold.has_package|d(False)) }}"
action: "remove"
- path: "tox.ini"
if: "{{ not scaffold.use_python }}"
action: "remove"