mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
84eabc42da
commit
207ff0df06
9 changed files with 15 additions and 15 deletions
|
|
@ -9,7 +9,7 @@ function M:peek()
|
||||||
return ya.preview_widgets(self, {
|
return ya.preview_widgets(self, {
|
||||||
ui.Text(
|
ui.Text(
|
||||||
code == 2 and "File list in this archive is encrypted"
|
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),
|
):area(self.area),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
@ -64,7 +64,7 @@ function M.spawn_7z(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not child then
|
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
|
end
|
||||||
return child, last_err
|
return child, last_err
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ function M:try_with(from, pwd, to)
|
||||||
local archive = require("archive")
|
local archive = require("archive")
|
||||||
local child, err = archive.spawn_7z { "x", "-aou", "-sccUTF-8", "-p" .. pwd, "-o" .. tostring(tmp), tostring(from) }
|
local child, err = archive.spawn_7z { "x", "-aou", "-sccUTF-8", "-p" .. pwd, "-o" .. tostring(tmp), tostring(from) }
|
||||||
if not child then
|
if not child then
|
||||||
fail("Starting both `7z` and `7zz` failed, error: " .. err)
|
fail("Failed to start both `7z` and `7zz`, error: " .. err)
|
||||||
end
|
end
|
||||||
|
|
||||||
local output, err = child:wait_with_output()
|
local output, err = child:wait_with_output()
|
||||||
|
|
@ -61,7 +61,7 @@ function M:try_with(from, pwd, to)
|
||||||
|
|
||||||
self:tidy(from, to, tmp)
|
self:tidy(from, to, tmp)
|
||||||
if not output then
|
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
|
elseif output.status.code ~= 0 then
|
||||||
fail("7zip exited when extracting '%s', error code %s", from, output.status.code)
|
fail("7zip exited when extracting '%s', error code %s", from, output.status.code)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@ local M = {}
|
||||||
|
|
||||||
function M:peek()
|
function M:peek()
|
||||||
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
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
|
local text
|
||||||
if output then
|
if output then
|
||||||
text = ui.Text.parse("----- File Type Classification -----\n\n" .. output.stdout)
|
text = ui.Text.parse("----- File Type Classification -----\n\n" .. output.stdout)
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
ya.preview_widgets(self, { text:area(self.area):wrap(ui.Text.WRAP) })
|
ya.preview_widgets(self, { text:area(self.area):wrap(ui.Text.WRAP) })
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ function M:preload()
|
||||||
}):spawn()
|
}):spawn()
|
||||||
|
|
||||||
if not child then
|
if not child then
|
||||||
ya.err("Starting `magick` failed, error: " .. err)
|
ya.err("Failed to start `magick`, error: " .. err)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ local function entry()
|
||||||
Command("fzf"):cwd(cwd):stdin(Command.INHERIT):stdout(Command.PIPED):stderr(Command.INHERIT):spawn()
|
Command("fzf"):cwd(cwd):stdin(Command.INHERIT):stdout(Command.PIPED):stderr(Command.INHERIT):spawn()
|
||||||
|
|
||||||
if not child then
|
if not child then
|
||||||
return fail("Starting `fzf` failed, error: " .. err)
|
return fail("Failed to start `fzf`, error: " .. err)
|
||||||
end
|
end
|
||||||
|
|
||||||
local output, err = child:wait_with_output()
|
local output, err = child:wait_with_output()
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ function M:preload()
|
||||||
}):spawn()
|
}):spawn()
|
||||||
|
|
||||||
if not child then
|
if not child then
|
||||||
ya.err("Starting `magick` failed, error: " .. err)
|
ya.err("Failed to start `magick`, error: " .. err)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ function M:fetch(job)
|
||||||
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
||||||
local child, err = Command(cmd):args({ "-bL", "--mime-type", "--" }):args(urls):stdout(Command.PIPED):spawn()
|
local child, err = Command(cmd):args({ "-bL", "--mime-type", "--" }):args(urls):stdout(Command.PIPED):spawn()
|
||||||
if not child then
|
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
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ function M:preload()
|
||||||
}):spawn()
|
}):spawn()
|
||||||
|
|
||||||
if not child then
|
if not child then
|
||||||
ya.err("Starting `ffmpeg` failed, error: " .. err)
|
ya.err("Failed to start `ffmpeg`, error: " .. err)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -116,14 +116,14 @@ function M.list_meta(url, entries)
|
||||||
local output, err =
|
local output, err =
|
||||||
Command("ffprobe"):args({ "-v", "quiet", "-show_entries", entries, "-of", "json=c=1", tostring(url) }):output()
|
Command("ffprobe"):args({ "-v", "quiet", "-show_entries", entries, "-of", "json=c=1", tostring(url) }):output()
|
||||||
if not output then
|
if not output then
|
||||||
return nil, Err("Spawn `ffprobe` process returns %s", err)
|
return nil, Err("Failed to start `ffprobe`, error: " .. err)
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = ya.json_decode(output.stdout)
|
local t = ya.json_decode(output.stdout)
|
||||||
if not t then
|
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
|
elseif type(t) ~= "table" then
|
||||||
return nil, Err("Invalid `ffprobe` output: %s", output.stdout)
|
return nil, Err("Invalid `ffprobe` output: " .. output.stdout)
|
||||||
end
|
end
|
||||||
|
|
||||||
t.format = t.format or {}
|
t.format = t.format or {}
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ local function entry()
|
||||||
:spawn()
|
:spawn()
|
||||||
|
|
||||||
if not child then
|
if not child then
|
||||||
return fail("Starting `zoxide` failed, error: " .. err)
|
return fail("Failed to start `zoxide`, error: " .. err)
|
||||||
end
|
end
|
||||||
|
|
||||||
local output, err = child:wait_with_output()
|
local output, err = child:wait_with_output()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue