refactor: simplify
This commit is contained in:
+16
-16
@@ -1,5 +1,21 @@
|
||||
local M = {}
|
||||
|
||||
--- Interactive picker for selecting and running tasks defined in a Justfile.
|
||||
function M.pick_just_task()
|
||||
local obj = vim.system({ "just", "--summary" }, { text = true }):wait()
|
||||
if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then
|
||||
return vim.notify("No recipes or justfile found", vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
require("mini.pick").start({
|
||||
source = {
|
||||
items = vim.split(vim.trim(obj.stdout), "%s+"),
|
||||
name = " Just Tasks",
|
||||
choose = function(choice) run_task("just " .. choice) end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
local function run_task(cmd)
|
||||
vim.notify(" Running: " .. cmd)
|
||||
|
||||
@@ -20,20 +36,4 @@ local function run_task(cmd)
|
||||
end)
|
||||
end
|
||||
|
||||
--- Interactive picker for selecting and running tasks defined in a Justfile.
|
||||
function M.pick_just_task()
|
||||
local obj = vim.system({ "just", "--summary" }, { text = true }):wait()
|
||||
if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then
|
||||
return vim.notify("No recipes or justfile found", vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
require("mini.pick").start({
|
||||
source = {
|
||||
items = vim.split(vim.trim(obj.stdout), "%s+"),
|
||||
name = " Just Tasks",
|
||||
choose = function(choice) run_task("just " .. choice) end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user