|
| 1 | +--- Gleam language actions |
| 2 | + |
| 3 | +local M = {} |
| 4 | + |
| 5 | +-- Frontend - options displayed on telescope |
| 6 | +M.options = { |
| 7 | + { text = "Gleam build and run", value = "option1" }, |
| 8 | + { text = "Gleam build", value = "option2" }, |
| 9 | + { text = "Gleam run", value = "option3" }, |
| 10 | +} |
| 11 | + |
| 12 | +-- Backend - overseer tasks performed on option selected |
| 13 | +function M.action(selected_option) |
| 14 | + local overseer = require("overseer") |
| 15 | + local final_message = "--task finished--" |
| 16 | + |
| 17 | + if selected_option == "option1" then |
| 18 | + local task = overseer.new_task({ |
| 19 | + name = "- Gleam compiler", |
| 20 | + strategy = { "orchestrator", |
| 21 | + tasks = {{ name = "- gleam build & run → " .. "\"./gleam.toml\"", |
| 22 | + cmd = "gleam build " .. -- compile |
| 23 | + " && gleam run" .. -- run |
| 24 | + " && echo \"" .. final_message .. "\"", -- echo |
| 25 | + components = { "default_extended" } |
| 26 | + },},},}) |
| 27 | + task:start() |
| 28 | + elseif selected_option == "option2" then |
| 29 | + local task = overseer.new_task({ |
| 30 | + name = "- Gleam compiler", |
| 31 | + strategy = { "orchestrator", |
| 32 | + tasks = {{ name = "- gleam build → " .. "\"./gleam.toml\"", |
| 33 | + cmd = "gleam build " .. -- compile |
| 34 | + " && echo \"" .. final_message .. "\"", -- echo |
| 35 | + components = { "default_extended" } |
| 36 | + },},},}) |
| 37 | + task:start() |
| 38 | + elseif selected_option == "option3" then |
| 39 | + local task = overseer.new_task({ |
| 40 | + name = "- Gleam compiler", |
| 41 | + strategy = { "orchestrator", |
| 42 | + tasks = {{ name = "- gleam run → " .. "\"./gleam.toml\"", |
| 43 | + cmd = "gleam run " .. -- compile |
| 44 | + " && echo \"" .. final_message .. "\"", -- echo |
| 45 | + components = { "default_extended" } |
| 46 | + },},},}) |
| 47 | + task:start() |
| 48 | + end |
| 49 | +end |
| 50 | + |
| 51 | +return M |
| 52 | + |
| 53 | + |
0 commit comments