mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-07-31 14:17:45 +00:00
replace filter
with where
(#1135)
This PR tries to clean up the use of `filter` by replacing it with `where`. I did not test each script. closes #1134 closes #1133
This commit is contained in:
parent
84c25bbc6d
commit
32cdc96414
25 changed files with 66 additions and 66 deletions
|
@ -28,7 +28,7 @@ export def 'from tree' [
|
|||
if not ($fst in ['list', 'record']) {
|
||||
$acc
|
||||
} else {
|
||||
let r = $acc.schema | filter {|i| ($i | get $selector.value) == $x}
|
||||
let r = $acc.schema | where {|i| ($i | get $selector.value) == $x}
|
||||
if ($r | is-empty) {
|
||||
$acc
|
||||
} else {
|
||||
|
|
|
@ -97,7 +97,7 @@ export def image-select [name] {
|
|||
let imgs = (image-list)
|
||||
let fs = [image tag repo]
|
||||
for i in 2..0 {
|
||||
let r = $imgs | filter {|x|
|
||||
let r = $imgs | where {|x|
|
||||
$fs | slice 0..$i | all {|y| ($n | get $y) == ($x | get $y) }
|
||||
}
|
||||
if ($r | is-not-empty) {
|
||||
|
|
|
@ -60,7 +60,7 @@ def "nu-complete git log" [] {
|
|||
def "nu-complete git branches" [] {
|
||||
git branch
|
||||
| lines
|
||||
| filter {|x| not ($x | str starts-with '*')}
|
||||
| where {|x| not ($x | str starts-with '*')}
|
||||
| each {|x| $"($x|str trim)"}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ def list_merged [
|
|||
|
||||
run-external "git" "branch" ...$args
|
||||
| lines
|
||||
| filter {|branch|
|
||||
| where {|branch|
|
||||
$keep
|
||||
| all {|pattern|
|
||||
$branch !~ $'\A($pattern)\z'
|
||||
|
|
|
@ -101,7 +101,7 @@ export def gb [
|
|||
git branch -D $b
|
||||
}
|
||||
if ($dels | is-not-empty) and (agree 'delete remote branch?!') {
|
||||
for b in ($dels | filter { $"($remote)/($in)" in $remote_branches }) {
|
||||
for b in ($dels | where { $"($remote)/($in)" in $remote_branches }) {
|
||||
tips $"delete (ansi yellow)($remote)/($b)"
|
||||
git branch -D -r $'($remote)/($b)'
|
||||
git push $remote -d $b
|
||||
|
@ -657,13 +657,13 @@ def "nu-complete git branch files" [context: string, offset:int] {
|
|||
let files = $token | skip 2
|
||||
git ls-tree -r --name-only $branch
|
||||
| lines
|
||||
| filter {|x| not ($x in $files)}
|
||||
| where {|x| not ($x in $files)}
|
||||
}
|
||||
|
||||
def "nu-complete git branches" [] {
|
||||
git branch
|
||||
| lines
|
||||
| filter {|x| not ($x | str starts-with '*')}
|
||||
| where {|x| not ($x | str starts-with '*')}
|
||||
| each {|x| $"($x|str trim)"}
|
||||
}
|
||||
|
||||
|
@ -671,7 +671,7 @@ export def remote_branches [] {
|
|||
git branch -r
|
||||
| lines
|
||||
| str trim
|
||||
| filter {|x| not ($x | str starts-with 'origin/HEAD') }
|
||||
| where {|x| not ($x | str starts-with 'origin/HEAD') }
|
||||
}
|
||||
|
||||
def "nu-complete git remotes" [] {
|
||||
|
|
|
@ -3,7 +3,7 @@ def quote [...t] {
|
|||
}
|
||||
|
||||
def flatten_fields [args] {
|
||||
let f = $in | default [] | filter {|x| $x | is-not-empty }
|
||||
let f = $in | default [] | where {|x| $x | is-not-empty }
|
||||
let prefix = $args.0
|
||||
let inner = $args.1
|
||||
let outer = $args.2
|
||||
|
|
|
@ -16,7 +16,7 @@ export def kube-refine [
|
|||
let cns = kubectl get namespace
|
||||
| from ssv -a
|
||||
| get NAME
|
||||
| filter $nsf
|
||||
| where $nsf
|
||||
|
||||
let resource = kubectl get crd | from ssv | get NAME
|
||||
let resource = kubectl api-resources | from ssv -a | get NAME | append $resource
|
||||
|
@ -24,7 +24,7 @@ export def kube-refine [
|
|||
$resource
|
||||
} else {
|
||||
$resource
|
||||
| filter {|x| $x in $kind }
|
||||
| where {|x| $x in $kind }
|
||||
}
|
||||
|
||||
mut data = []
|
||||
|
|
|
@ -77,7 +77,7 @@ export def --wrapped level [
|
|||
| each (do $env.lg.line_formatter $theme $align $mkl)
|
||||
| str join (char newline)
|
||||
let head = [$time $label $txt]
|
||||
| filter {|x| $x | is-not-empty }
|
||||
| where {|x| $x | is-not-empty }
|
||||
| str join $theme.delimiter
|
||||
[$head $body] | str join (char newline)
|
||||
} else {
|
||||
|
@ -85,7 +85,7 @@ export def --wrapped level [
|
|||
| each {|y| $"($theme.bg)($y.k)=($theme.fg)($y.v)"}
|
||||
| str join ' '
|
||||
[$time $label $tag $txt]
|
||||
| filter {|x| $x | is-not-empty }
|
||||
| where {|x| $x | is-not-empty }
|
||||
| str join $theme.delimiter
|
||||
}
|
||||
$r + $theme.terminal | do $output
|
||||
|
|
|
@ -3,5 +3,5 @@ export def ls-hidden [
|
|||
--dir(-d):any # The directory you want to list
|
||||
] {
|
||||
let dir = if ($dir | is-empty) { "." } else { $dir }
|
||||
ls -a $dir | filter { ($in.name | into string | str starts-with '.') }
|
||||
ls -a $dir | where { ($in.name | into string | str starts-with '.') }
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ flag_record:record # A object filled all known flags and their values.
|
|||
|
||||
|
||||
}
|
||||
| filter { |value| ( $value | describe ) != nothing }
|
||||
| where { |value| ( $value | describe ) != nothing }
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue