This commit is contained in:
sxyazi 2024-11-23 18:24:25 +08:00
parent 84eabc42da
commit 207ff0df06
No known key found for this signature in database
9 changed files with 15 additions and 15 deletions

View file

@ -9,7 +9,7 @@ function M:peek()
return ya.preview_widgets(self, {
ui.Text(
code == 2 and "File list in this archive is encrypted"
or "Starting both `7z` and `7zz` failed. Do you have 7-zip installed?"
or "Failed to start both `7z` and `7zz`. Do you have 7-zip installed?"
):area(self.area),
})
end
@ -64,7 +64,7 @@ function M.spawn_7z(args)
end
if not child then
return ya.err("Starting both `7z` and `7zz` failed, error: " .. last_err)
return ya.err("Failed to start both `7z` and `7zz`, error: " .. last_err)
end
return child, last_err
end

View file

@ -50,7 +50,7 @@ function M:try_with(from, pwd, to)
local archive = require("archive")
local child, err = archive.spawn_7z { "x", "-aou", "-sccUTF-8", "-p" .. pwd, "-o" .. tostring(tmp), tostring(from) }
if not child then
fail("Starting both `7z` and `7zz` failed, error: " .. err)
fail("Failed to start both `7z` and `7zz`, error: " .. err)
end
local output, err = child:wait_with_output()
@ -61,7 +61,7 @@ function M:try_with(from, pwd, to)
self:tidy(from, to, tmp)
if not output then
fail("7zip failed to output when extracting '%s', error code %s", err, from)
fail("7zip failed to output when extracting '%s', error: %s", from, err)
elseif output.status.code ~= 0 then
fail("7zip exited when extracting '%s', error code %s", from, output.status.code)
end

View file

@ -2,13 +2,13 @@ local M = {}
function M:peek()
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
local output, code = Command(cmd):args({ "-bL", "--", tostring(self.file.url) }):stdout(Command.PIPED):output()
local output, err = Command(cmd):args({ "-bL", "--", tostring(self.file.url) }):stdout(Command.PIPED):output()
local text
if output then
text = ui.Text.parse("----- File Type Classification -----\n\n" .. output.stdout)
else
text = ui.Text(string.format("Starting `%s` failed with error code %s. Do you have file(1) installed?", cmd, code))
text = ui.Text(string.format("Failed to start `%s`, error: %s", cmd, err))
end
ya.preview_widgets(self, { text:area(self.area):wrap(ui.Text.WRAP) })

View file

@ -40,7 +40,7 @@ function M:preload()
}):spawn()
if not child then
ya.err("Starting `magick` failed, error: " .. err)
ya.err("Failed to start `magick`, error: " .. err)
return 0
end

View file

@ -10,7 +10,7 @@ local function entry()
Command("fzf"):cwd(cwd):stdin(Command.INHERIT):stdout(Command.PIPED):stderr(Command.INHERIT):spawn()
if not child then
return fail("Starting `fzf` failed, error: " .. err)
return fail("Failed to start `fzf`, error: " .. err)
end
local output, err = child:wait_with_output()

View file

@ -33,7 +33,7 @@ function M:preload()
}):spawn()
if not child then
ya.err("Starting `magick` failed, error: " .. err)
ya.err("Failed to start `magick`, error: " .. err)
return 0
end

View file

@ -18,7 +18,7 @@ function M:fetch(job)
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
local child, err = Command(cmd):args({ "-bL", "--mime-type", "--" }):args(urls):stdout(Command.PIPED):spawn()
if not child then
ya.err(string.format("Starting `%s` failed, error: %s", cmd, err))
ya.err(string.format("Failed to start `%s`, error: %s", cmd, err))
return 0
end

View file

@ -62,7 +62,7 @@ function M:preload()
}):spawn()
if not child then
ya.err("Starting `ffmpeg` failed, error: " .. err)
ya.err("Failed to start `ffmpeg`, error: " .. err)
return 0
end
@ -116,14 +116,14 @@ function M.list_meta(url, entries)
local output, err =
Command("ffprobe"):args({ "-v", "quiet", "-show_entries", entries, "-of", "json=c=1", tostring(url) }):output()
if not output then
return nil, Err("Spawn `ffprobe` process returns %s", err)
return nil, Err("Failed to start `ffprobe`, error: " .. err)
end
local t = ya.json_decode(output.stdout)
if not t then
return nil, Err("Failed to decode `ffprobe` output: %s", output.stdout)
return nil, Err("Failed to decode `ffprobe` output: " .. output.stdout)
elseif type(t) ~= "table" then
return nil, Err("Invalid `ffprobe` output: %s", output.stdout)
return nil, Err("Invalid `ffprobe` output: " .. output.stdout)
end
t.format = t.format or {}

View file

@ -101,7 +101,7 @@ local function entry()
:spawn()
if not child then
return fail("Starting `zoxide` failed, error: " .. err)
return fail("Failed to start `zoxide`, error: " .. err)
end
local output, err = child:wait_with_output()