mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
Update remoting.nu (#239)
Running built-in command using `ssh script` fails with a non-obvious error message. This fixes that
This commit is contained in:
parent
abd600d41e
commit
456c0fe5b0
1 changed files with 17 additions and 4 deletions
|
@ -61,11 +61,24 @@ export def "ssh script" [
|
||||||
script: string@"nu-complete scripts" # name of the script
|
script: string@"nu-complete scripts" # name of the script
|
||||||
...args # arguments you wish to pass to the script in key=value format
|
...args # arguments you wish to pass to the script in key=value format
|
||||||
] {
|
] {
|
||||||
let host = (hosts|where name == $hostname|get 0)
|
let span = (metadata $script).span
|
||||||
let full-command = (build-string (view-source $script) '; ' $script ' ' ($args|str collect ' ') '|to json -r')
|
if $script in ($nu.scope.commands|where is_custom|get command) {
|
||||||
^ssh (get-url $host) ($full-command)|from json
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let host = (hosts|where name == $hostname|get 0)
|
||||||
|
let full-command = (build-string (view-source $script) '; ' $script ' ' ($args|str collect ' ') '|to json -r')
|
||||||
|
^ssh (get-url $host) ($full-command)|from json
|
||||||
|
|
||||||
|
} else {
|
||||||
|
error make {
|
||||||
|
msg: $"($script) is not a custom command, use regular ssh command instead"
|
||||||
|
label: {
|
||||||
|
text: "Not a custom command",
|
||||||
|
start: $span.start,
|
||||||
|
end: $span.end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
# Turns on specified hosts using Wake on Lan
|
# Turns on specified hosts using Wake on Lan
|
||||||
export def wake [
|
export def wake [
|
||||||
...names: string@"nu-complete wol" # list of host names to wake
|
...names: string@"nu-complete wol" # list of host names to wake
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue