From 56fe4b94ff351d629efce837e0d692f24cb2edbf Mon Sep 17 00:00:00 2001 From: fj0r <82698591+fj0r@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:45:50 +0800 Subject: [PATCH] standardized parameter naming for `--help` and fix regex capture (#786) standardized parameter naming for `--help` |old|new| |-|-| |img|image| |ctn|container| |p|file| |ctx|context| |ns|namespace| |k|kind| |r, i|resource| |r|pod, service, deployment| |res|kind| |svc|service| |d, dpl|deployment| change `(?P)` to `(?)` Co-authored-by: nash --- modules/docker/docker.nu | 60 +++++------ modules/git/git-v2.nu | 8 +- modules/kubernetes/kubernetes.nu | 172 +++++++++++++++---------------- modules/network/ssh.nu | 2 +- 4 files changed, 121 insertions(+), 121 deletions(-) diff --git a/modules/docker/docker.nu b/modules/docker/docker.nu index 7675b541..9c7c8f84 100644 --- a/modules/docker/docker.nu +++ b/modules/docker/docker.nu @@ -79,9 +79,9 @@ export def container-list [ # list images export def image-list [ -n: string@"nu-complete docker ns" - img?: string@"nu-complete docker images" + image?: string@"nu-complete docker images" ] { - if ($img | is-empty) { + if ($image | is-empty) { ^$env.docker-cli ...($n | with-flag -n) images | from ssv -a | each {|x| @@ -99,7 +99,7 @@ export def image-list [ } } } else { - let r = ^$env.docker-cli ...($n | with-flag -n) inspect $img + let r = ^$env.docker-cli ...($n | with-flag -n) inspect $image | from json | get 0 let e = $r.Config.Env? @@ -170,48 +170,48 @@ def "nu-complete docker images" [] { # container log export def container-log [ - ctn: string@"nu-complete docker containers" + container: string@"nu-complete docker containers" -l: int = 100 # line -n: string@"nu-complete docker ns" # namespace ] { let l = if $l == 0 { [] } else { [--tail $l] } - ^$env.docker-cli ...($n | with-flag -n) logs -f ...$l $ctn + ^$env.docker-cli ...($n | with-flag -n) logs -f ...$l $container } export def container-log-trunc [ - ctn: string@"nu-complete docker containers" + container: string@"nu-complete docker containers" -n: string@"nu-complete docker ns" # namespace ] { if $env.docker-cli == 'podman' { print -e $'(ansi yellow)podman(ansi dark_gray) isn’t supported(ansi reset)' } else { - let f = ^$env.docker-cli ...($n | with-flag -n) inspect --format='{{.LogPath}}' $ctn + let f = ^$env.docker-cli ...($n | with-flag -n) inspect --format='{{.LogPath}}' $container truncate -s 0 $f } } # attach container export def --wrapped container-attach [ - ctn: string@"nu-complete docker containers" + container: string@"nu-complete docker containers" -n: string@"nu-complete docker ns" ...args ] { let ns = $n | with-flag -n if ($args|is-empty) { - ^$env.docker-cli ...$ns exec -it $ctn /bin/sh -c "[ -e /bin/zsh ] && /bin/zsh || [ -e /bin/bash ] && /bin/bash || /bin/sh" + ^$env.docker-cli ...$ns exec -it $container /bin/sh -c "[ -e /bin/zsh ] && /bin/zsh || [ -e /bin/bash ] && /bin/bash || /bin/sh" } else { - ^$env.docker-cli ...$ns exec -it $ctn ...$args + ^$env.docker-cli ...$ns exec -it $container ...$args } } def "nu-complete docker cp" [cmd: string, offset: int] { let argv = $cmd | str substring ..$offset | split row ' ' let p = if ($argv | length) > 2 { $argv | get 2 } else { $argv | get 1 } - let ctn = ^$env.docker-cli ps + let container = ^$env.docker-cli ps | from ssv -a | each {|x| {description: $x.'CONTAINER ID' value: $"($x.NAMES):" }} let n = $p | split row ':' - if $"($n | get 0):" in ($ctn | get value) { + if $"($n | get 0):" in ($container | get value) { ^$env.docker-cli exec ($n | get 0) sh -c $"ls -dp ($n | get 1)*" | lines | each {|x| $"($n | get 0):($x)"} @@ -220,7 +220,7 @@ def "nu-complete docker cp" [cmd: string, offset: int] { ls -a ($"($p)*" | into glob) | each {|x| if $x.type == dir { $"($x.name)/"} else { $x.name }} } - $files | append $ctn + $files | append $container } } @@ -233,20 +233,20 @@ export def container-copy-file [ } # remove container -export def container-remove [ctn: string@"nu-complete docker containers" -n: string@"nu-complete docker ns"] { - ^$env.docker-cli ...($n | with-flag -n) container rm -f $ctn +export def container-remove [container: string@"nu-complete docker containers" -n: string@"nu-complete docker ns"] { + ^$env.docker-cli ...($n | with-flag -n) container rm -f $container } # history -export def container-history [img: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] { - ^$env.docker-cli ...($n | with-flag -n) history --no-trunc $img | from ssv -a +export def container-history [image: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] { + ^$env.docker-cli ...($n | with-flag -n) history --no-trunc $image | from ssv -a } # save images -export def image-save [-n: string@"nu-complete docker ns" ...img: string@"nu-complete docker images"] { - ^$env.docker-cli ...($n | with-flag -n) save ...$img +export def image-save [-n: string@"nu-complete docker ns" ...image: string@"nu-complete docker images"] { + ^$env.docker-cli ...($n | with-flag -n) save ...$image } # load images @@ -265,8 +265,8 @@ export def system-prune-all [-n: string@"nu-complete docker ns"] { } # remove image -export def image-remove [img: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] { - ^$env.docker-cli ...($n | with-flag -n) rmi $img +export def image-remove [image: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] { + ^$env.docker-cli ...($n | with-flag -n) rmi $image } # add new tag @@ -276,15 +276,15 @@ export def image-tag [from: string@"nu-complete docker images" to: string -n: s # push image export def image-push [ - img: string@"nu-complete docker images" + image: string@"nu-complete docker images" --tag(-t): string -n: string@"nu-complete docker ns" -i ] { let $insecure = if $i {[--insecure-registry]} else {[]} if ($tag | is-empty) { - ^$env.docker-cli ...($n | with-flag -n) ...$insecure push $img + ^$env.docker-cli ...($n | with-flag -n) ...$insecure push $image } else { - ^$env.docker-cli ...($n | with-flag -n) tag $img $tag + ^$env.docker-cli ...($n | with-flag -n) tag $image $tag do -i { ^$env.docker-cli ...($n | with-flag -n) ...$insecure push $tag } @@ -293,9 +293,9 @@ export def image-push [ } # pull image -export def image-pull [img -n: string@"nu-complete docker ns" -i] { +export def image-pull [image -n: string@"nu-complete docker ns" -i] { let $insecure = if $i {[--insecure-registry]} else {[]} - ^$env.docker-cli ...($n | with-flag -n) ...$insecure pull $img + ^$env.docker-cli ...($n | with-flag -n) ...$insecure pull $image } ### list volume @@ -371,7 +371,7 @@ export def container-create [ --with-x --privileged(-P) --namespace(-n): string@"nu-complete docker ns" - img: string@"nu-complete docker images" # image + image: string@"nu-complete docker images" # image ...cmd # command args ] { let ns = $namespace | with-flag -n @@ -409,11 +409,11 @@ export def container-create [ $debug $appimage $netadmin $with_x $mnt $vols $workdir $cache ] | flatten - let name = $"($img | split row '/' | last | str replace ':' '-')_(date now | format date %m%d%H%M)" + let name = $"($image | split row '/' | last | str replace ':' '-')_(date now | format date %m%d%H%M)" if $dry_run { - echo ([docker $ns run --name $name $args $img $cmd] | flatten | str join ' ') + echo ([docker $ns run --name $name $args $image $cmd] | flatten | str join ' ') } else { - ^$env.docker-cli ...$ns run --name $name ...$args $img ...($cmd | flatten) + ^$env.docker-cli ...$ns run --name $name ...$args $image ...($cmd | flatten) } } diff --git a/modules/git/git-v2.nu b/modules/git/git-v2.nu index 2a7b1170..92a2b6c0 100644 --- a/modules/git/git-v2.nu +++ b/modules/git/git-v2.nu @@ -1,4 +1,4 @@ -use ../argx/argx.nu +use argx.nu def agree [ prompt @@ -119,7 +119,7 @@ export def gb [ } else if ($branch | is-empty) { let merged = git branch --merged | lines - | each { $in | parse -r '\s*\*?\s*(?P[^\s]+)' | get 0.b } + | each { $in | parse -r '\s*\*?\s*(?[^\s]+)' | get 0.b } { local: (git branch) remote: (git branch --remote) @@ -128,7 +128,7 @@ export def gb [ | each {|x| $x.v | lines | each {|n| - let n = $n | parse -r '\s*(?P\*)?\s*(?P[^\s]+)( -> )?(?P[^\s]+)?' | get 0 + let n = $n | parse -r '\s*(?\*)?\s*(?[^\s]+)( -> )?(?[^\s]+)?' | get 0 let c = if ($n.c | is-empty) { null } else { true } let r = if ($n.r | is-empty) { null } else { $n.r } let m = if $n.b in $merged { true } else { null } @@ -595,7 +595,7 @@ export def _git_log_stat [n] { | split row ',' | each {|x| $x | str trim - | parse -r "(?P[0-9]+) (?P.+)" + | parse -r "(?[0-9]+) (?.+)" | get 0 } | reduce -f {sha: $acc.c file:0 ins:0 del:0} {|i,a| diff --git a/modules/kubernetes/kubernetes.nu b/modules/kubernetes/kubernetes.nu index a583ac99..75ea629c 100644 --- a/modules/kubernetes/kubernetes.nu +++ b/modules/kubernetes/kubernetes.nu @@ -45,38 +45,38 @@ export-env { # kubectl apply -f -export def kaf [p: path] { - kubectl apply -f $p +export def kaf [file: path] { + kubectl apply -f $file } # kubectl diff -f -export def kdf [p: path] { - kubectl diff -f $p +export def kdf [file: path] { + kubectl diff -f $file } # kubectl delete -f -export def kdelf [p: path] { - kubectl delete -f $p +export def kdelf [file: path] { + kubectl delete -f $file } # kubectl apply -k (kustomize) -export def kak [p: path] { - kubectl apply -k $p +export def kak [file: path] { + kubectl apply -k $file } # kubectl diff -k (kustomize) -export def kdk [p: path] { - kubectl diff -k $p +export def kdk [file: path] { + kubectl diff -k $file } # kubectl delete -k (kustomize) -export def kdelk [p: path] { - kubectl delete -k $p +export def kdelk [file: path] { + kubectl delete -k $file } # kubectl kustomize (template) -export def kk [p: path] { - kubectl kustomize $p +export def kk [file: path] { + kubectl kustomize $file } ### ctx @@ -121,20 +121,20 @@ def "nu-complete kube ns" [] { } # kubectl change context -export def kcc [ctx: string@"nu-complete kube ctx"] { - kubectl config use-context $ctx +export def kcc [context: string@"nu-complete kube ctx"] { + kubectl config use-context $context } # kubectl (change) namespace -export def kn [ns: string@"nu-complete kube ns"] { - if not ($ns in (kubectl get namespace | from ssv -a | get NAME)) { - if ([no yes] | input list $"namespace '($ns)' doesn't exist, create it?") in [yes] { - kubectl create namespace $ns +export def kn [namespace: string@"nu-complete kube ns"] { + if not ($namespace in (kubectl get namespace | from ssv -a | get NAME)) { + if ([no yes] | input list $"namespace '($namespace)' doesn't exist, create it?") in [yes] { + kubectl create namespace $namespace } else { return } } - kubectl config set-context --current $"--namespace=($ns)" + kubectl config set-context --current $"--namespace=($namespace)" } def parse_cellpath [path] { @@ -312,8 +312,8 @@ def "nu-complete kube jsonpath" [context: string] { # kubectl get export def kg [ - k: string@"nu-complete kube kind" - r?: string@"nu-complete kube res" + kind: string@"nu-complete kube kind" + resource?: string@"nu-complete kube res" --namespace (-n): string@"nu-complete kube ns" --jsonpath (-p): string@"nu-complete kube jsonpath" --selector (-l): string @@ -329,12 +329,12 @@ export def kg [ } else { [-n $namespace] } - if ($r | is-empty) { + if ($resource | is-empty) { let l = $selector | with-flag -l if ($jsonpath | is-empty) { let wide = if $wide {[-o wide]} else {[]} if ($verbose) { - kubectl get -o json ...$n $k ...$l | from json | get items + kubectl get -o json ...$n $kind ...$l | from json | get items | each {|x| { name: $x.metadata.name @@ -348,74 +348,74 @@ export def kg [ } | normalize-column-names } else if $watch { - kubectl get ...$n $k ...$l ...$wide --watch + kubectl get ...$n $kind ...$l ...$wide --watch } else { - kubectl get ...$n $k ...$l ...$wide | from ssv -a | normalize-column-names + kubectl get ...$n $kind ...$l ...$wide | from ssv -a | normalize-column-names } } else { - kubectl get ...$n $k $"--output=jsonpath={($jsonpath)}" | from json + kubectl get ...$n $kind $"--output=jsonpath={($jsonpath)}" | from json } } else { - kubectl get ...$n $k $r -o json | from json + kubectl get ...$n $kind $resource -o json | from json } } # kubectl describe export def kd [ - r: string@"nu-complete kube kind" - i: string@"nu-complete kube res" + kind: string@"nu-complete kube kind" + resource: string@"nu-complete kube res" --namespace (-n): string@"nu-complete kube ns" ] { - kubectl describe ...($namespace | with-flag -n) $r $i + kubectl describe ...($namespace | with-flag -n) $kind $resource } # kubectl create export def kc [ - r: string@"nu-complete kube kind" + kind: string@"nu-complete kube kind" --namespace (-n): string@"nu-complete kube ns" name:string ] { - kubectl create ...($namespace | with-flag -n) $r $name + kubectl create ...($namespace | with-flag -n) $kind $name } # kubectl get -o yaml export def ky [ - r: string@"nu-complete kube kind" - i: string@"nu-complete kube res" + kind: string@"nu-complete kube kind" + resource: string@"nu-complete kube res" --namespace (-n): string@"nu-complete kube ns" ] { - kubectl get ...($namespace | with-flag -n) -o yaml $r $i + kubectl get ...($namespace | with-flag -n) -o yaml $kind $resource } # kubectl edit export def ke [ - k: string@"nu-complete kube kind" - r?: string@"nu-complete kube res" + kind: string@"nu-complete kube kind" + resource?: string@"nu-complete kube res" --namespace (-n): string@"nu-complete kube ns" --selector(-l): string ] { let n = $namespace | with-flag -n - let r = if ($selector | is-empty) { $r } else { - let res = kubectl get $k ...$n -l $selector | from ssv -a | each {|x| $x.NAME} + let r = if ($selector | is-empty) { $resource } else { + let res = kubectl get $kind ...$n -l $selector | from ssv -a | each {|x| $x.NAME} if ($res | length) == 1 { $res.0 } else if ($res | length) == 0 { return } else { - $res | input list $'select ($k) ' + $res | input list $'select ($kind) ' } } - kubectl edit ...$n $k $r + kubectl edit ...$n $kind $r } # kubectl delete export def kdel [ - r: string@"nu-complete kube kind" - i: string@"nu-complete kube res" + kind: string@"nu-complete kube kind" + resource: string@"nu-complete kube res" --namespace (-n): string@"nu-complete kube ns" --force(-f) ] { - kubectl delete ...($namespace | with-flag -n) ...(if $force {[--grace-period=0 --force]} else {[]}) $r $i + kubectl delete ...($namespace | with-flag -n) ...(if $force {[--grace-period=0 --force]} else {[]}) $kind $resource } @@ -457,36 +457,36 @@ def "nu-complete kube ctns" [context: string, offset: int] { # kubectl get pods export def kgp [ - r?: string@"nu-complete kube res via name" + pod?: string@"nu-complete kube res via name" --namespace (-n): string@"nu-complete kube ns" --jsonpath (-p): string@"nu-complete kube jsonpath" --selector (-l): string --all (-a) ] { - if ($r | is-not-empty) { - kubectl get pods ...($namespace | with-flag -n) $r --output=json + if ($pod | is-not-empty) { + kubectl get pods ...($namespace | with-flag -n) $pod --output=json | from json | {...$in.metadata, ...$in.spec, ...$in.status} } else if $all { kg pods -a --wide } else { - kg pods -n $namespace -p $jsonpath -l $selector --wide $r + kg pods -n $namespace -p $jsonpath -l $selector --wide $pod } } # kubectl get pods --watch export def kwp [ - r?: string@"nu-complete kube res via name" + pod?: string@"nu-complete kube res via name" --namespace (-n): string@"nu-complete kube ns" --selector (-l): string ] { - kg pods -n $namespace -w -l $selector --wide $r + kg pods -n $namespace -w -l $selector --wide $pod } # kubectl edit pod export def kep [ --namespace (-n): string@"nu-complete kube ns" - pod?: string@"nu-complete kube res via name" + pod: string@"nu-complete kube res via name" --selector (-l): string ] { ke -n $namespace pod -l $selector $pod @@ -589,7 +589,7 @@ def "nu-complete kube port" [context: string, offset: int] { # kubectl port-forward export def kpf [ - res: string@"nu-complete port forward type" + kind: string@"nu-complete port forward type" target: string@"nu-complete kube res" port: string@"nu-complete kube port" --local (-l): string @@ -597,7 +597,7 @@ export def kpf [ ] { let ns = $namespace | with-flag -n let port = if ($local | is-empty) { $port } else { $"($local):($port)" } - kubectl port-forward ...$ns $"($res)/($target)" $port + kubectl port-forward ...$ns $"($kind)/($target)" $port } def "nu-complete kube cp" [cmd: string, offset: int] { @@ -630,15 +630,15 @@ export def kcp [ # kubectl get services export def kgs [ - r?: string@"nu-complete kube res via name" + service?: string@"nu-complete kube res via name" --namespace (-n): string@"nu-complete kube ns" --jsonpath (-p): string@"nu-complete kube jsonpath" --selector (-l): string ] { - if ($r | is-empty) { - kg services -n $namespace -p $jsonpath -l $selector $r + if ($service | is-empty) { + kg services -n $namespace -p $jsonpath -l $selector $service } else { - kubectl get svc ...($namespace | with-flag -n) $r --output=json + kubectl get svc ...($namespace | with-flag -n) $service --output=json | from json | {...$in.metadata, ...$in.spec, ...$in.status} } @@ -646,44 +646,44 @@ export def kgs [ # kubectl edit service export def kes [ - svc?: string@"nu-complete kube res via name" + service?: string@"nu-complete kube res via name" --namespace (-n): string@"nu-complete kube ns" --selector (-l): string ] { - ke -n $namespace service -l $selector $svc + ke -n $namespace service -l $selector $service } # kubectl delete service export def kdels [ - svc: string@"nu-complete kube res via name" + service: string@"nu-complete kube res via name" --namespace (-n): string@"nu-complete kube ns" ] { - kdel -n $namespace service $svc + kdel -n $namespace service $service } # kubectl get deployments export def kgd [ - r?: string@"nu-complete kube res via name" + deployment?: string@"nu-complete kube res via name" --namespace (-n): string@"nu-complete kube ns" --jsonpath (-p): string@"nu-complete kube jsonpath" --selector (-l): string ] { - kg -n $namespace deployments -p $jsonpath -l $selector $r + kg -n $namespace deployments -p $jsonpath -l $selector $deployment } # kubectl edit deployment export def ked [ - d?: string@"nu-complete kube res via name" + deployment?: string@"nu-complete kube res via name" --namespace (-n): string@"nu-complete kube ns" --selector (-l): string ] { - ke -n $namespace deployments -l $selector $d + ke -n $namespace deployments -l $selector $deployment } def "nu-complete num9" [] { [0 1 2 3] } # kubectl scale deployment export def ksd [ - d: string@"nu-complete kube deploys" + deployment: string@"nu-complete kube deploys" num: string@"nu-complete num9" --namespace (-n): string@"nu-complete kube ns" ] { @@ -691,13 +691,13 @@ export def ksd [ "too large" } else { let ns = $namespace | with-flag -n - kubectl scale ...$ns deployments $d --replicas $num + kubectl scale ...$ns deployments $deployment --replicas $num } } # kubectl scale deployment with reset export def ksdr [ - d: string@"nu-complete kube deploys" + deployment: string@"nu-complete kube deploys" num: int@"nu-complete num9" --namespace (-n): string@"nu-complete kube ns" ] { @@ -707,8 +707,8 @@ export def ksdr [ "too small" } else { let ns = $namespace | with-flag -n - kubectl scale ...$ns deployments $d --replicas 0 - kubectl scale ...$ns deployments $d --replicas $num + kubectl scale ...$ns deployments $deployment --replicas 0 + kubectl scale ...$ns deployments $deployment --replicas $num } } @@ -723,23 +723,23 @@ def "nu-complete kube kind with image" [] { # kubectl set image export def ksi [ - k: string@"nu-complete kube kind with image" - r: string@"nu-complete kube res" + kind: string@"nu-complete kube kind with image" + resource: string@"nu-complete kube res" --namespace(-n): string@"nu-complete kube ns" act?: any ] { let ns = $namespace | with-flag -n - let path = match $k { + let path = match $kind { _ => '.spec.template.spec.containers[*]' } - let name = kubectl get ...$ns $k $r -o $"jsonpath={($path).name}" | split row ' ' - let image = kubectl get ...$ns $k $r -o $"jsonpath={($path).image}" | split row ' ' + let name = kubectl get ...$ns $kind $resource -o $"jsonpath={($path).name}" | split row ' ' + let image = kubectl get ...$ns $kind $resource -o $"jsonpath={($path).image}" | split row ' ' let list = $name | zip $image | reduce -f {} {|it,acc| $acc | insert $it.0 $it.1 } if ($act | describe -d).type == 'closure' { let s = do $act $list if ($s | describe -d).type == 'record' { let s = $s | transpose k v | each {|x| $"($x.k)=($x.v)"} - kubectl ...$ns set image $"($k)/($r)" ...$s + kubectl ...$ns set image $"($kind)/($resource)" ...$s } } else { $list @@ -748,14 +748,14 @@ export def ksi [ # kubectl redistribution deployment export def krd [ - d: string@"nu-complete kube deploys" + deployment: string@"nu-complete kube deploys" ...nodes: string@"nu-complete kube nodes" --namespace (-n): string@"nu-complete kube ns" ] { let ns = $namespace | with-flag -n let nums = kubectl get nodes | from ssv -a | length - kubectl scale ...$ns deployments $d --replicas $nums - let labels = kubectl get ...$ns deploy $d --output=json + kubectl scale ...$ns deployments $deployment --replicas $nums + let labels = kubectl get ...$ns deploy $deployment --output=json | from json | get spec.selector.matchLabels | transpose k v @@ -765,7 +765,7 @@ export def krd [ for p in ($pods | where NODE not-in $nodes) { kubectl delete ...$ns pod --grace-period=0 --force $p.NAME } - kubectl scale ...$ns deployments $d --replicas ($pods | where NODE in $nodes | length) + kubectl scale ...$ns deployments $deployment --replicas ($pods | where NODE in $nodes | length) } # kubectl rollout status deployment @@ -777,22 +777,22 @@ export alias kgrs = kubectl get rs export def krhd [ --namespace (-n): string@"nu-complete kube ns" --revision (-v): int - dpl: string@"nu-complete kube res via name" + deployment: string@"nu-complete kube res via name" ] { let ns = $namespace | with-flag -n let v = if ($revision|is-empty) { [] } else { [ $"--revision=($revision)" ] } - kubectl ...$ns rollout history $"deployment/($dpl)" ...$v + kubectl ...$ns rollout history $"deployment/($deployment)" ...$v } # kubectl rollout undo export def krud [ --namespace (-n): string@"nu-complete kube ns" --revision (-v): int - dpl: string@"nu-complete kube res via name" + deployment: string@"nu-complete kube res via name" ] { let ns = $namespace | with-flag -n let v = if ($revision|is-empty) { [] } else { [ $"--to-revision=($revision)" ] } - kubectl ...$ns rollout undo $"deployment/($dpl)" ...$v + kubectl ...$ns rollout undo $"deployment/($deployment)" ...$v } export alias ksss = kubectl scale statefulset export alias krsss = kubectl rollout status statefulset diff --git a/modules/network/ssh.nu b/modules/network/ssh.nu index 6a8863a6..52b52af0 100644 --- a/modules/network/ssh.nu +++ b/modules/network/ssh.nu @@ -31,7 +31,7 @@ def "nu-complete ssh host" [] { export def parse-ssh-file [group] { $in - | parse -r '(?PHost|HostName|User|Port|IdentityFile)\s+(?P.+)' + | parse -r '(?Host|HostName|User|Port|IdentityFile)\s+(?.+)' | append { k: Host, v: null} | reduce -f { rst: [], item: {Host: null} } {|it, acc| if $it.k == 'Host' {