Fix.
parent
215725e8ce
commit
d23a05e1a3
35
main.lua
35
main.lua
|
|
@ -1,23 +1,37 @@
|
|||
local notify = function(text)
|
||||
ya.notify({
|
||||
title = "Rip",
|
||||
content = text,
|
||||
timeout = 2,
|
||||
})
|
||||
end
|
||||
|
||||
local selected_or_hovered = ya.sync(function()
|
||||
local tab, urls = cx.active, {}
|
||||
if #tab.selected > 0 then
|
||||
for _, u in pairs(tab.selected) do
|
||||
urls[#urls + 1] = { name = u:name(), url = tostring(u) }
|
||||
urls[#urls + 1] = tostring(u)
|
||||
end
|
||||
end
|
||||
if #urls == 0 and tab.current.hovered then
|
||||
urls[1] = { name = tab.current.hovered.url:name(), url = tostring(tab.current.hovered.url) }
|
||||
urls[1] = tostring(tab.current.hovered.url)
|
||||
end
|
||||
return urls
|
||||
end)
|
||||
|
||||
local confirm_remove = function(file)
|
||||
local title = "Remove " .. file.name .. "? y/n/a/c "
|
||||
local title = "Remove " .. file .. "? y/n/a/c "
|
||||
local w = #title
|
||||
local input = ya.input({
|
||||
local input, event = ya.input({
|
||||
title = title,
|
||||
value = "y",
|
||||
position = { "top-center", w = w },
|
||||
position = { "center", w = w },
|
||||
})
|
||||
|
||||
if event ~= 1 then
|
||||
return "c"
|
||||
end
|
||||
|
||||
if input == "y" then
|
||||
return "y"
|
||||
elseif input == "a" then
|
||||
|
|
@ -44,23 +58,20 @@ local remove_file = function(file)
|
|||
timeout = 2,
|
||||
})
|
||||
end
|
||||
|
||||
local status, err = Command("rip"):arg(file.url):status()
|
||||
local status, err = Command("rip"):arg(file):status()
|
||||
if not status or status.code ~= 0 then
|
||||
notify_error(file.name)
|
||||
notify_error(file)
|
||||
else
|
||||
notify_success(file.name)
|
||||
notify_success(file)
|
||||
end
|
||||
end
|
||||
|
||||
--- @sync entry
|
||||
return {
|
||||
entry = function()
|
||||
ya.manager_emit("escape", { visual = true })
|
||||
|
||||
ya.mgr_emit("escape", { visual = true })
|
||||
local files = selected_or_hovered()
|
||||
local confirm_all = false
|
||||
|
||||
for _, file in ipairs(files) do
|
||||
if not confirm_all then
|
||||
local should_remove = confirm_remove(file)
|
||||
|
|
|
|||
Loading…
Reference in New Issue