refactor: simplify the sudo demo for better readability
This commit is contained in:
@@ -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).
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user