1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-03 07:37:47 +00:00

Add compatibility note about Nu version (#1057)

This is my response for #1051 

The syntax of this note is inspired by Rust _Cargo.toml_ and Python
_pyproject.toml_.
This commit is contained in:
Nguyễn Hồng Quân 2025-02-24 19:27:50 +07:00 committed by GitHub
parent 1e7fdd4427
commit 1da73cf106
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View file

@ -1,3 +1,5 @@
# nu-version: 0.102.0
export extern "ssh" [
destination?: string@"nu-complete ssh-host"
-4 # Forces ssh to use IPv4 addresses only.
@ -41,11 +43,12 @@ module ssh-completion-utils {
# │ 4 │ │
# ╰───┴──────────────────────────────╯
let host = $in
let name = $host | get 0 | str trim | split row -r '\s+' | get 1
let $first_line = try { $host | first | str trim } catch { null }
# Don't accept blocks like "Host *"
if ('*' in $name) {
if ($first_line | is-empty) or '*' in $first_line {
null
} else {
let name = $first_line | split row -r '\s+' | get 1
# May not contain hostname
match ($host | slice 1.. | find -ir '^\s*Hostname\s') {
[] => null,
@ -68,7 +71,7 @@ module ssh-completion-utils {
includes: $include_lines
}
}
}