1
Fork 0
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:
Darren Schroeder 2025-06-12 06:42:16 -05:00 committed by GitHub
parent 84c25bbc6d
commit 32cdc96414
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 66 additions and 66 deletions

View file

@ -279,7 +279,7 @@ def columns [
]
if not ($query | is-empty) {
$columns = $columns | filter {
$columns = $columns | where {
$in | str contains --ignore-case $query
}
}

View file

@ -14,7 +14,7 @@ def "nu-complete flutter commands" [] {
| into string
| str replace --regex --multiline '(Manage[\s\S]*(?=Flutter SDK))' ''
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| each { str trim }
| parse "{value} {description}"
| str trim
@ -33,7 +33,7 @@ def "nu-complete pub commands" [] {
| into string
| str replace --regex --multiline '(Commands[\s\S]*(?=Available subcommands))' ''
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| each { str trim }
| parse "{value} {description}"
| str trim

View file

@ -2,7 +2,7 @@
def "nu-complete gh" [] {
^gh --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -16,7 +16,7 @@ export extern "gh" [
def "nu-complete gh auth" [] {
^gh auth --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -43,7 +43,7 @@ export extern "gh browse" [
def "nu-complete gh codespace" [] {
^gh codespace --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -57,7 +57,7 @@ export extern "gh codespace" [
def "nu-complete gh gist" [] {
^gh gist --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -129,7 +129,7 @@ export extern "gh gist view" [
def "nu-complete gh issue" [] {
^gh issue --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -144,7 +144,7 @@ export extern "gh issue" [
def "nu-complete gh org" [] {
^gh org --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -156,7 +156,7 @@ export extern "gh org" [
]
def "nu-complete gh pr" [] {
^gh pr --help | lines | filter { str starts-with " " } | skip 1 | parse "{value}: {description}" | str trim
^gh pr --help | lines | where { str starts-with " " } | skip 1 | parse "{value}: {description}" | str trim
}
export extern "gh pr" [
@ -182,7 +182,7 @@ export extern "gh pr checkout" [
def "nu-complete gh project" [] {
^gh project --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -196,7 +196,7 @@ export extern "gh project" [
def "nu-complete gh release" [] {
^gh release --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -211,7 +211,7 @@ export extern "gh release" [
def "nu-complete gh repo" [] {
^gh repo --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -310,7 +310,7 @@ export extern "gh repo fork" [
def "nu-complete gh cache" [] {
^gh cache --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -325,7 +325,7 @@ export extern "gh cache" [
def "nu-complete gh run" [] {
^gh run --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -339,7 +339,7 @@ export extern "gh run" [
def "nu-complete gh workflow" [] {
^gh workflow --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -354,7 +354,7 @@ export extern "gh workflow" [
def "nu-complete gh alias" [] {
^gh alias --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -403,7 +403,7 @@ export extern "gh completion" [
def "nu-complete gh config" [] {
^gh config --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -417,7 +417,7 @@ export extern "gh config" [
def "nu-complete gh extension" [] {
^gh extension --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -431,7 +431,7 @@ export extern "gh extension" [
def "nu-complete gh gpg-key" [] {
^gh gpg-key --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -445,7 +445,7 @@ export extern "gh gpg-key" [
def "nu-complete gh label" [] {
^gh label --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -460,7 +460,7 @@ export extern "gh label" [
def "nu-complete gh ruleset" [] {
^gh ruleset --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -475,7 +475,7 @@ export extern "gh ruleset" [
def "nu-complete gh search" [] {
^gh search --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -501,7 +501,7 @@ export extern "gh search" [
def "nu-complete gh secret" [] {
^gh secret --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -516,7 +516,7 @@ export extern "gh secret" [
def "nu-complete gh ssh-key" [] {
^gh ssh-key --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
@ -536,7 +536,7 @@ export extern "gh status" [
def "nu-complete gh variable" [] {
^gh variable --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim

View file

@ -37,7 +37,7 @@ def "nu-complete args" [context:string,offset:int] {
def get-just-arg [name:string,position:int] {
let recipes = (
get-recipes
| filter {|r| $r.name == $name }
| where {|r| $r.name == $name }
| get parameters
| flatten)
let len = $recipes | length

View file

@ -85,7 +85,7 @@ def "nu-complete kw configs" [] {
def "nu-complete kw remotes" [] {
^kw remote --list
| lines
| filter {|line| not ($line | str contains " ")}
| where {|line| not ($line | str contains " ")}
}
# The inglorious kernel developer workflow tool

View file

@ -44,7 +44,7 @@ module lftp-completion-utils {
let files = [
'/etc/ssh/ssh_config',
'~/.ssh/config'
] | filter {|file| $file | path exists }
] | where {|file| $file | path exists }
let first_result: record<hosts: list<record<name: string, addr: string>>, includes: list<string>> = $files | par-each {|file|

View file

@ -34,7 +34,7 @@ def "nu-complete mask args" [context: string, offset: int] {
$rt ++= ($c | get named_flags | each {|x|
let v = if not ($x.long | is-empty) { $"`--($x.long)`" } else if not ($x.short | is-empty) { $"`-($x.short)`" } else { $"---($x.name)" }
let a = ["required", "multiple", "takes_value", "validate_as_number"]
| filter {|y| ($x | get $y) == true }
| where {|y| ($x | get $y) == true }
| str join ','
let d = if ($a | is-empty) { $x.description } else { $"($x.description) \(($a))" }
{value: $v , description: $d }

View file

@ -21,7 +21,7 @@ export def "nu-complete pass-directories" [] {
let dir = (pass_completions_directory)
ls ($dir | path join **)
| get name
| filter { |it| not (ls $it | is-empty) }
| where { |it| not (ls $it | is-empty) }
| each {|it| ( $it | path relative-to $dir) }
}

View file

@ -5,7 +5,7 @@ export extern "rye" [
def "nu-complete rye" [] {
^rye --help
| lines
| filter { str starts-with " " }
| where { str starts-with " " }
| each {str trim}
| parse "{value} {description}"
| str trim
@ -120,7 +120,7 @@ def "nu-complete rye tools" [] {
^rye tools --help
| lines
| drop 1
| filter { str starts-with " " }
| where { str starts-with " " }
| each {str trim}
| parse "{value} {description}"
| str trim
@ -135,7 +135,7 @@ def "nu-complete rye self" [] {
^rye self --help
| lines
| drop 1
| filter { str starts-with " " }
| where { str starts-with " " }
| each {str trim}
| parse "{value} {description}"
| str trim
@ -150,7 +150,7 @@ def "nu-complete rye toolchain" [] {
^rye toolchain --help
| lines
| drop 1
| filter { str starts-with " " }
| where { str starts-with " " }
| each {str trim}
| parse "{value} {description}"
| str trim

View file

@ -79,7 +79,7 @@ def "nu-complete ssh-host" [] {
let files = [
'/etc/ssh/ssh_config',
'~/.ssh/config'
] | filter {|file| $file | path exists }
] | where {|file| $file | path exists }
use ssh-completion-utils process

View file

@ -369,7 +369,7 @@ export def "winget list" [
(do $flagify help $help)
]
| flatten
| filter { not ($in | is-empty) })
| where { not ($in | is-empty) })
)
let output = ^winget ...$params