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> - no group field per question
  • Every group in order must have questions (no empty groups)
  • Group names appear in TUI and --questions

Question fields

Field Description
key Variable name for Prebyte/{{ key }}
type string, bool, choice, …
prompt Display text
default Value or function(ctx) … end
alias Alternative keys (e.g. name_slug for project_slug)
optional true if empty is allowed
choices For type = "choice"
condition function(ctx) return bool end - question only when true
validate function(ctx) return true | "error message" end
sensitive true - masked input (API tokens)
help Additional 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)
  return slugify(ctx.values.project_name or "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