refactor: simplify the sudo demo for better readability

This commit is contained in:
sxyazi
2024-11-12 08:53:02 +08:00
parent dc118798fb
commit fb3ae9093b
2 changed files with 3 additions and 4 deletions

View File

@@ -14,8 +14,8 @@ Add this to your `~/.config/yazi/keymap.toml`:
```toml
[[manager.prepend_keymap]]
on = "<C-t>"
run = "plugin sudo-demo"
on = "<C-t>"
run = "plugin sudo-demo"
```
Press <kbd>Ctrl</kbd> + <kbd>t</kbd> to run the plugin, you should [see a message in the log](https://yazi-rs.github.io/docs/plugins/overview#logging).

View File

@@ -14,7 +14,7 @@ end
--- nil: no error
--- 1: sudo failed
local function run_with_sudo(program, args)
local cmd = Command("sudo"):args({ program, table.unpack(args) }):stdout(Command.PIPED):stderr(Command.PIPED)
local cmd = Command("sudo"):args { program, table.unpack(args) }
if sudo_already() then
return cmd:output()
end
@@ -38,7 +38,6 @@ return {
end
ya.err("stdout", output.stdout)
ya.err("stderr", output.stderr)
ya.err("status.code", output.status.code)
end,
}