Variables
Collecting user input with Variables
Variables
Variables allow you to make your templates dynamic by collecting input from the user.
# Variable Structure
Each variable in the variables list supports the following fields:
| Field | Type | Description |
|---|---|---|
name | string | Required. The key used to access this value in templates (e.g., {{ .myVar }}). |
kind | string | Required. The type of input. |
prompt | string | Required. The question to ask the user. |
default | string | array | The default value if the user presses Enter. |
options | array | List of options for select and multiselect kinds. |
if | string | A condition to determine if this variable should be prompted. |
# Variable Kinds
# Basic Inputs
input: Standard text input.secret: Input is masked (useful for API keys).confirm: A Yes/No toggle. Returnstrueorfalse.
# Selection
select: Choose one option from a list.multiselect: Choose multiple options. Returns an array of strings.
- name: database
kind: select
prompt: Choose a database
options:
- postgres
- mysql
- sqlite
# Specialized Inputs
Skela provides specialized inputs with built-in validation or behavior:
project-name: Prompts for a valid directory name.project-path: Select a directory path.go-module: Validates input as a Go module path.go-version: Prompts for a Go version.package-manager: Selects fromnpm,pnpm,yarn,bun.license: Selects a standard open-source license.git-init: Confirms if Git should be initialized (boolean).
# Conditional Variables
You can show or hide variables based on previous answers using the if field.
- name: useDb
kind: confirm
prompt: Do you need a database?
- name: dbType
kind: select
prompt: Which database?
options: [postgres, sqlite]
if: "{{ .useDb }}"