Skip to content

Commit 32cdc96

Browse files
authored
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
1 parent 84c25bb commit 32cdc96

File tree

25 files changed

+66
-66
lines changed

25 files changed

+66
-66
lines changed

custom-completions/cargo-loco/cargo-loco-completions.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def columns [
279279
]
280280

281281
if not ($query | is-empty) {
282-
$columns = $columns | filter {
282+
$columns = $columns | where {
283283
$in | str contains --ignore-case $query
284284
}
285285
}

custom-completions/flutter/flutter-completions.nu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def "nu-complete flutter commands" [] {
1414
| into string
1515
| str replace --regex --multiline '(Manage[\s\S]*(?=Flutter SDK))' ''
1616
| lines
17-
| filter { str starts-with " " }
17+
| where { str starts-with " " }
1818
| each { str trim }
1919
| parse "{value} {description}"
2020
| str trim
@@ -33,7 +33,7 @@ def "nu-complete pub commands" [] {
3333
| into string
3434
| str replace --regex --multiline '(Commands[\s\S]*(?=Available subcommands))' ''
3535
| lines
36-
| filter { str starts-with " " }
36+
| where { str starts-with " " }
3737
| each { str trim }
3838
| parse "{value} {description}"
3939
| str trim

custom-completions/gh/gh-completions.nu

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
def "nu-complete gh" [] {
33
^gh --help
44
| lines
5-
| filter { str starts-with " " }
5+
| where { str starts-with " " }
66
| skip 1
77
| parse "{value}: {description}"
88
| str trim
@@ -16,7 +16,7 @@ export extern "gh" [
1616
def "nu-complete gh auth" [] {
1717
^gh auth --help
1818
| lines
19-
| filter { str starts-with " " }
19+
| where { str starts-with " " }
2020
| skip 1
2121
| parse "{value}: {description}"
2222
| str trim
@@ -43,7 +43,7 @@ export extern "gh browse" [
4343
def "nu-complete gh codespace" [] {
4444
^gh codespace --help
4545
| lines
46-
| filter { str starts-with " " }
46+
| where { str starts-with " " }
4747
| skip 1
4848
| parse "{value}: {description}"
4949
| str trim
@@ -57,7 +57,7 @@ export extern "gh codespace" [
5757
def "nu-complete gh gist" [] {
5858
^gh gist --help
5959
| lines
60-
| filter { str starts-with " " }
60+
| where { str starts-with " " }
6161
| skip 1
6262
| parse "{value}: {description}"
6363
| str trim
@@ -129,7 +129,7 @@ export extern "gh gist view" [
129129
def "nu-complete gh issue" [] {
130130
^gh issue --help
131131
| lines
132-
| filter { str starts-with " " }
132+
| where { str starts-with " " }
133133
| skip 1
134134
| parse "{value}: {description}"
135135
| str trim
@@ -144,7 +144,7 @@ export extern "gh issue" [
144144
def "nu-complete gh org" [] {
145145
^gh org --help
146146
| lines
147-
| filter { str starts-with " " }
147+
| where { str starts-with " " }
148148
| skip 1
149149
| parse "{value}: {description}"
150150
| str trim
@@ -156,7 +156,7 @@ export extern "gh org" [
156156
]
157157

158158
def "nu-complete gh pr" [] {
159-
^gh pr --help | lines | filter { str starts-with " " } | skip 1 | parse "{value}: {description}" | str trim
159+
^gh pr --help | lines | where { str starts-with " " } | skip 1 | parse "{value}: {description}" | str trim
160160
}
161161

162162
export extern "gh pr" [
@@ -182,7 +182,7 @@ export extern "gh pr checkout" [
182182
def "nu-complete gh project" [] {
183183
^gh project --help
184184
| lines
185-
| filter { str starts-with " " }
185+
| where { str starts-with " " }
186186
| skip 1
187187
| parse "{value}: {description}"
188188
| str trim
@@ -196,7 +196,7 @@ export extern "gh project" [
196196
def "nu-complete gh release" [] {
197197
^gh release --help
198198
| lines
199-
| filter { str starts-with " " }
199+
| where { str starts-with " " }
200200
| skip 1
201201
| parse "{value}: {description}"
202202
| str trim
@@ -211,7 +211,7 @@ export extern "gh release" [
211211
def "nu-complete gh repo" [] {
212212
^gh repo --help
213213
| lines
214-
| filter { str starts-with " " }
214+
| where { str starts-with " " }
215215
| skip 1
216216
| parse "{value}: {description}"
217217
| str trim
@@ -310,7 +310,7 @@ export extern "gh repo fork" [
310310
def "nu-complete gh cache" [] {
311311
^gh cache --help
312312
| lines
313-
| filter { str starts-with " " }
313+
| where { str starts-with " " }
314314
| skip 1
315315
| parse "{value}: {description}"
316316
| str trim
@@ -325,7 +325,7 @@ export extern "gh cache" [
325325
def "nu-complete gh run" [] {
326326
^gh run --help
327327
| lines
328-
| filter { str starts-with " " }
328+
| where { str starts-with " " }
329329
| skip 1
330330
| parse "{value}: {description}"
331331
| str trim
@@ -339,7 +339,7 @@ export extern "gh run" [
339339
def "nu-complete gh workflow" [] {
340340
^gh workflow --help
341341
| lines
342-
| filter { str starts-with " " }
342+
| where { str starts-with " " }
343343
| skip 1
344344
| parse "{value}: {description}"
345345
| str trim
@@ -354,7 +354,7 @@ export extern "gh workflow" [
354354
def "nu-complete gh alias" [] {
355355
^gh alias --help
356356
| lines
357-
| filter { str starts-with " " }
357+
| where { str starts-with " " }
358358
| skip 1
359359
| parse "{value}: {description}"
360360
| str trim
@@ -403,7 +403,7 @@ export extern "gh completion" [
403403
def "nu-complete gh config" [] {
404404
^gh config --help
405405
| lines
406-
| filter { str starts-with " " }
406+
| where { str starts-with " " }
407407
| skip 1
408408
| parse "{value}: {description}"
409409
| str trim
@@ -417,7 +417,7 @@ export extern "gh config" [
417417
def "nu-complete gh extension" [] {
418418
^gh extension --help
419419
| lines
420-
| filter { str starts-with " " }
420+
| where { str starts-with " " }
421421
| skip 1
422422
| parse "{value}: {description}"
423423
| str trim
@@ -431,7 +431,7 @@ export extern "gh extension" [
431431
def "nu-complete gh gpg-key" [] {
432432
^gh gpg-key --help
433433
| lines
434-
| filter { str starts-with " " }
434+
| where { str starts-with " " }
435435
| skip 1
436436
| parse "{value}: {description}"
437437
| str trim
@@ -445,7 +445,7 @@ export extern "gh gpg-key" [
445445
def "nu-complete gh label" [] {
446446
^gh label --help
447447
| lines
448-
| filter { str starts-with " " }
448+
| where { str starts-with " " }
449449
| skip 1
450450
| parse "{value}: {description}"
451451
| str trim
@@ -460,7 +460,7 @@ export extern "gh label" [
460460
def "nu-complete gh ruleset" [] {
461461
^gh ruleset --help
462462
| lines
463-
| filter { str starts-with " " }
463+
| where { str starts-with " " }
464464
| skip 1
465465
| parse "{value}: {description}"
466466
| str trim
@@ -475,7 +475,7 @@ export extern "gh ruleset" [
475475
def "nu-complete gh search" [] {
476476
^gh search --help
477477
| lines
478-
| filter { str starts-with " " }
478+
| where { str starts-with " " }
479479
| skip 1
480480
| parse "{value}: {description}"
481481
| str trim
@@ -501,7 +501,7 @@ export extern "gh search" [
501501
def "nu-complete gh secret" [] {
502502
^gh secret --help
503503
| lines
504-
| filter { str starts-with " " }
504+
| where { str starts-with " " }
505505
| skip 1
506506
| parse "{value}: {description}"
507507
| str trim
@@ -516,7 +516,7 @@ export extern "gh secret" [
516516
def "nu-complete gh ssh-key" [] {
517517
^gh ssh-key --help
518518
| lines
519-
| filter { str starts-with " " }
519+
| where { str starts-with " " }
520520
| skip 1
521521
| parse "{value}: {description}"
522522
| str trim
@@ -536,7 +536,7 @@ export extern "gh status" [
536536
def "nu-complete gh variable" [] {
537537
^gh variable --help
538538
| lines
539-
| filter { str starts-with " " }
539+
| where { str starts-with " " }
540540
| skip 1
541541
| parse "{value}: {description}"
542542
| str trim

custom-completions/just/just-completions.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def "nu-complete args" [context:string,offset:int] {
3737
def get-just-arg [name:string,position:int] {
3838
let recipes = (
3939
get-recipes
40-
| filter {|r| $r.name == $name }
40+
| where {|r| $r.name == $name }
4141
| get parameters
4242
| flatten)
4343
let len = $recipes | length

custom-completions/kw/kw-completions.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def "nu-complete kw configs" [] {
8585
def "nu-complete kw remotes" [] {
8686
^kw remote --list
8787
| lines
88-
| filter {|line| not ($line | str contains " ")}
88+
| where {|line| not ($line | str contains " ")}
8989
}
9090

9191
# The inglorious kernel developer workflow tool

custom-completions/lftp/lftp-completions.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module lftp-completion-utils {
4444
let files = [
4545
'/etc/ssh/ssh_config',
4646
'~/.ssh/config'
47-
] | filter {|file| $file | path exists }
47+
] | where {|file| $file | path exists }
4848

4949

5050
let first_result: record<hosts: list<record<name: string, addr: string>>, includes: list<string>> = $files | par-each {|file|

custom-completions/mask/mask-completions.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def "nu-complete mask args" [context: string, offset: int] {
3434
$rt ++= ($c | get named_flags | each {|x|
3535
let v = if not ($x.long | is-empty) { $"`--($x.long)`" } else if not ($x.short | is-empty) { $"`-($x.short)`" } else { $"---($x.name)" }
3636
let a = ["required", "multiple", "takes_value", "validate_as_number"]
37-
| filter {|y| ($x | get $y) == true }
37+
| where {|y| ($x | get $y) == true }
3838
| str join ','
3939
let d = if ($a | is-empty) { $x.description } else { $"($x.description) \(($a))" }
4040
{value: $v , description: $d }

custom-completions/pass/nu-complete/mod.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export def "nu-complete pass-directories" [] {
2121
let dir = (pass_completions_directory)
2222
ls ($dir | path join **)
2323
| get name
24-
| filter { |it| not (ls $it | is-empty) }
24+
| where { |it| not (ls $it | is-empty) }
2525
| each {|it| ( $it | path relative-to $dir) }
2626
}
2727

custom-completions/rye/rye-completions.nu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export extern "rye" [
55
def "nu-complete rye" [] {
66
^rye --help
77
| lines
8-
| filter { str starts-with " " }
8+
| where { str starts-with " " }
99
| each {str trim}
1010
| parse "{value} {description}"
1111
| str trim
@@ -120,7 +120,7 @@ def "nu-complete rye tools" [] {
120120
^rye tools --help
121121
| lines
122122
| drop 1
123-
| filter { str starts-with " " }
123+
| where { str starts-with " " }
124124
| each {str trim}
125125
| parse "{value} {description}"
126126
| str trim
@@ -135,7 +135,7 @@ def "nu-complete rye self" [] {
135135
^rye self --help
136136
| lines
137137
| drop 1
138-
| filter { str starts-with " " }
138+
| where { str starts-with " " }
139139
| each {str trim}
140140
| parse "{value} {description}"
141141
| str trim
@@ -150,7 +150,7 @@ def "nu-complete rye toolchain" [] {
150150
^rye toolchain --help
151151
| lines
152152
| drop 1
153-
| filter { str starts-with " " }
153+
| where { str starts-with " " }
154154
| each {str trim}
155155
| parse "{value} {description}"
156156
| str trim

custom-completions/ssh/ssh-completions.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def "nu-complete ssh-host" [] {
7979
let files = [
8080
'/etc/ssh/ssh_config',
8181
'~/.ssh/config'
82-
] | filter {|file| $file | path exists }
82+
] | where {|file| $file | path exists }
8383

8484
use ssh-completion-utils process
8585

0 commit comments

Comments
 (0)