Skip to content

questions lua Reference

Leonard Ramminger edited this page Aug 22, 2026 · 1 revision

questions.lua Reference

Interactive and CLI-answerable questions.

Structure

return {
order= { "Project", "CI" },
groups= {
Project= {
{ key="project_name", type="string", prompt="Project name" },
{ key="project_slug", type="string" },
},
CI= {
{ key="include_ci", type="bool", prompt="Include CI?" },
},
},
}

Rules

  • order defines group order
  • Questions live in groups.<Name> - nogroup field per question
  • Every group in order must have questions (no empty groups)
  • Group names appear in TUI and --questions

Question fields

FieldDescription
keyVariable name for Prebyte/{{ key }}
typestring, bool, choice, …
promptDisplay text
defaultValue or function(ctx) … end
aliasAlternative keys (e.g. name_slug for project_slug)
optionaltrue if empty is allowed
choicesFor type = "choice"
conditionfunction(ctx) return bool end - question only when true
validatefunction(ctx) return true | "error message" end
sensitivetrue - masked input (API tokens)
helpAdditional help text

Context ctx

In default, condition, validate:

  • ctx.values - answers set so far (strings)
  • ctx.value - current input value (for validate)

slugify helper

Available in Lua hooks and questions.lua:

default=function(ctx)
returnslugify(ctx.values.project_nameor"my-app")
end

Export

tempify my_app --questions --json --full

See also

Questions & Answers · Reference: tests/test_templates/basic_cpp/questions.lua

Clone this wiki locally