select.lua
local t = require("terminal")
local Select = require("terminal.cli.select")
local Prompt = require("terminal.cli.prompt")
local function main()
t.text.push { fg = "cyan", brightness = "high" }
t.output.print("Welcome to the project setup wizard!")
t.text.pop()
t.output.print()
local idx, lang = Select {
prompt = "Pick a language:",
choices = {
"Lua",
"Python",
"JavaScript",
"Go",
},
cancellable = true,
clear = true,
}()
if not idx then
t.output.print("Setup cancelled.")
return
end
local _, license = Select {
prompt = "Choose a license:",
choices = {
"MIT",
"Apache-2.0",
"GPL-3.0",
"BSD-2-Clause",
},
cancellable = true,
clear = true,
}()
if not license then
t.output.print("Setup cancelled.")
return
end
t.output.print()
local name = Prompt {
prompt = "Project name: ",
value = "my-project",
max_length = 40,
cancellable = true,
}()
if not name then
t.output.print("Setup cancelled.")
return
end
t.output.print()
t.text.push { fg = "green", brightness = "high" }
t.output.print("Setup complete!")
t.text.pop()
t.text.push { brightness = "dim" }
t.output.write(" Language: ")
t.text.pop()
t.output.print(lang)
t.text.push { brightness = "dim" }
t.output.write(" License: ")
t.text.pop()
t.output.print(license)
t.text.push { brightness = "dim" }
t.output.write(" Name: ")
t.text.pop()
t.output.print(name)
t.output.print()
end
t.initwrap(main, {
disable_sigint = true, })()