fix substring for nu 0.94

This commit is contained in:
nash 2024-05-29 15:30:56 +08:00
parent 0d5e47e20e
commit 4db7930605
5 changed files with 14 additions and 14 deletions

View File

@ -290,7 +290,7 @@ export def --wrapped container-attach [
}
def "nu-complete docker cp" [cmd: string, offset: int] {
let argv = $cmd | str substring ..$offset | split row ' '
let argv = $cmd | str substring ..<$offset | split row ' '
let p = if ($argv | length) > 2 { $argv | get 2 } else { $argv | get 1 }
let container = ^$env.docker-cli ps
| from ssv -a

View File

@ -150,7 +150,7 @@ export def "nu-complete kube port" [context: string, offset: int] {
}
export def "nu-complete kube cp" [cmd: string, offset: int] {
let ctx = $cmd | str substring ..$offset | argx parse
let ctx = $cmd | str substring ..<$offset | argx parse
let p = $ctx._args | get (($ctx._args | length) - 1)
let ns = $ctx.namespace? | with-flag -n
let c = $ctx.container? | with-flag -c

View File

@ -36,7 +36,7 @@ export def kgh [
| from json
| update updated {|x|
$x.updated
| str substring ..-4
| str substring ..<-4
| into datetime -f '%Y-%m-%d %H:%M:%S.%f %z'
}
} else {

View File

@ -266,7 +266,7 @@ export def --wrapped ka [
let n = $namespace | with-flag -n
let pod = if ($selector | is-empty) {
if ($pod | str ends-with '-') {
$"deployment/($pod | str substring ..-1)"
$"deployment/($pod | str substring ..<-1)"
} else {
$pod
}
@ -314,7 +314,7 @@ export def kl [
let f = if $follow {[-f]} else {[]}
let p = if $previous {[-p]} else {[]}
let trg = if ($pod | str ends-with '-') {
$"deployment/($pod | str substring ..-1)"
$"deployment/($pod | str substring ..<-1)"
} else {
$pod
}
@ -513,8 +513,8 @@ export def ktp [
{
namespace: $x.namespace
name: $x.name
cpu: ($x.cpu| str substring ..-1 | into float)
mem: ($x.mem | str substring ..-2 | into float)
cpu: ($x.cpu| str substring ..<-1 | into float)
mem: ($x.mem | str substring ..<-2 | into float)
}
}
} else {
@ -523,8 +523,8 @@ export def ktp [
| each {|x|
{
name: $x.name
cpu: ($x.cpu| str substring ..-1 | into float)
mem: ($x.mem | str substring ..-2 | into float)
cpu: ($x.cpu| str substring ..<-1 | into float)
mem: ($x.mem | str substring ..<-2 | into float)
}
}
}
@ -535,10 +535,10 @@ export def ktno [] {
kubectl top node | from ssv -a | rename name cpu pcpu mem pmem
| each {|x| {
name: $x.name
cpu: ($x.cpu| str substring ..-1 | into float)
cpu%: (($x.pcpu| str substring ..-1 | into float) / 100)
mem: ($x.mem | str substring ..-2 | into float)
mem%: (($x.pmem | str substring ..-1 | into float) / 100)
cpu: ($x.cpu| str substring ..<-1 | into float)
cpu%: (($x.pcpu| str substring ..<-1 | into float) / 100)
mem: ($x.mem | str substring ..<-2 | into float)
mem%: (($x.pmem | str substring ..<-1 | into float) / 100)
} }
}

View File

@ -1,5 +1,5 @@
def "nu-complete scp" [cmd: string, offset: int] {
let argv = ($cmd | str substring ..$offset | split row ' ')
let argv = ($cmd | str substring ..<$offset | split row ' ')
let p = if ($argv | length) > 2 { $argv | get 2 } else { $argv | get 1 }
let ssh = (ssh-hosts | get completion
| each {|x| {value: $"($x.value):" description: $x.uri} }