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 specifying a folder as the the project template.
Nevertheless, you are free to name the file as you wish and specify it directly on the command line.
Sections
questions
name: The name of the variable to export.
description:
if: Jinja string, or boolean. Whether to ask the question or not.
hidden: Defaults to False. A hidden field will not be prompted to user. Supports jinja2 templating.
Schema options:
type: Defaults to string, but can also be boolean or integer.
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.
min_value:
max_value:
allowed: List of values that are accepted.
---
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"
hidden: True
schema:
default: "{{ scaffold.creation_year | d(year) }}"
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
Actions
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.
action: One of “move”, “remove”
Actions:
move: Move file from src to dst.
---
actions:
- action: "move"
if: "{{ scaffold.license | lower == 'mit' }}"
src: "LICENSE.MIT"
dst: "LICENSE"
else: "remove"
- action: "move"
if: "{{ scaffold.license | lower == 'gpl-3.0-or-later' }}"
src: "LICENSE.GPL-3.0-or-later"
dst: "LICENSE"
else: "remove"
- action: "remove"
if: "{{ scaffold.license | lower == 'none' }}"
path: [ "LICENSE", "LICENSE.MIT", "LICENSE.GPL-3.0-or-later" ]