1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 14:47:47 +00:00

Switch to 'and' and 'or' (#322)

* Switch to 'and' and 'or'

* oops
This commit is contained in:
JT 2022-12-08 12:52:10 +13:00 committed by GitHub
parent fe5c307390
commit 6f9d6250d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 104 additions and 101 deletions

View file

@ -70,7 +70,7 @@ def unquote [] {
# remove any entries which contain things in subcommands that may be fish functions or incorrect parses
def cleanup_subcommands [] {
where (not ($it.a | str contains "$")) && (not ($it.a | str starts-with "-")) && (not ($it.a starts-with "("))
where (not ($it.a | str contains "$")) and (not ($it.a | str starts-with "-")) and (not ($it.a starts-with "("))
}
# from a parsed fish table, create the completion for it's command and sub commands
@ -95,7 +95,7 @@ def make-subcommands-completion [parents: list] {
| transpose name args # turn it into a table of name to arguments
| each {|subcommand|
build-string (
if ('d' in ($subcommand.args | columns)) && ($subcommand.args.d != "") {
if ('d' in ($subcommand.args | columns)) and ($subcommand.args.d != "") {
build-string "# " ($subcommand.args.d.0) "\n" # (sub)command description
}) "extern " $quote ($parents | str collect " ") (
if $subcommand.name != "" {
@ -106,7 +106,7 @@ def make-subcommands-completion [parents: list] {
if ($subcommand.name != "") {
where ($it.n | str contains $subcommand.name) # for subcommand -> any where n matches `__fish_seen_subcommand_from arg` for the subcommand name
} else {
where ($it.n == "__fish_use_subcommand") && ($it.a == "") # for root command -> any where n == __fish_use_subcommand and a is empty. otherwise a means a subcommand
where ($it.n == "__fish_use_subcommand") and ($it.a == "") # for root command -> any where n == __fish_use_subcommand and a is empty. otherwise a means a subcommand
}
} else {
$fishes # catch all
@ -120,11 +120,11 @@ def make-subcommands-completion [parents: list] {
# build the list of flag string in nu syntax
def build-flags [] {
each { |subargs|
if ('l' in ($subargs | columns)) && ($subargs.l != "") {
if ('l' in ($subargs | columns)) and ($subargs.l != "") {
build-string "\t--" $subargs.l (build-string
(if ('s' in ($subargs | columns)) && ($subargs.s != "") {
(if ('s' in ($subargs | columns)) and ($subargs.s != "") {
build-string "(-" $subargs.s ")"
}) (if ('d' in ($subargs | columns)) && ($subargs.d != "") {
}) (if ('d' in ($subargs | columns)) and ($subargs.d != "") {
build-string "\t\t\t\t\t# " $subargs.d
})
)

View file

@ -81,7 +81,7 @@ def "winget show" [
(do $flagify help $help)
] | str collect ' ')
if $raw || $help {
if $raw or $help {
^$command
} else {
let output = (^$command | lines)
@ -129,7 +129,7 @@ def "winget source list" [
(do $flagify help $help)
] | str collect ' ')
if $raw || $help {
if $raw or $help {
^$command
} else {
let output = (^$command | lines)
@ -202,7 +202,7 @@ def "winget search" [
(do $flagify help $help)
] | str collect ' ')
if $raw || $help {
if $raw or $help {
^$command
} else {
let output = (^$command | lines)
@ -250,7 +250,7 @@ def "winget list" [
(do $flagify help $help)
] | str collect ' ')
if $help || $raw {
if $help or $raw {
^$command
} else {
let output = (^$command | lines)
@ -374,7 +374,7 @@ def "nu-complete winget source type" [] {
def "nu-complete winget flagify" [name: string, value: any, --short(-s): bool] {
let flag_start = if $short { '-' } else { '--' }
if $value == $nothing || $value == false {
if $value == $nothing or $value == false {
""
} else if $value == true {
$"($flag_start)($name)"
@ -397,7 +397,7 @@ def "nu-complete winget uninstall package name" [] {
def "nu-complete winget install name" [] {
let path = ($env.TMP | path join winget-packages.csv)
let completions = if ($path | path exists) && (ls $path | first | get modified | ((date now) - $in) < 1day) {
let completions = if ($path | path exists) and (ls $path | first | get modified | ((date now) - $in) < 1day) {
open $path | get name | each { |it| $"(char dq)($it)(char dq)" } | str replace "…" ""
} else {
# Chinese characters break parsing, filter broken entries with `where source == winget`
@ -417,7 +417,7 @@ def "nu-complete winget install name" [] {
def "nu-complete winget install id" [] {
let path = ($env.TMP | path join winget-packages.csv)
if ($path | path exists) && (ls $path | first | get modified | ((date now) - $in) < 1day) {
if ($path | path exists) and (ls $path | first | get modified | ((date now) - $in) < 1day) {
open $path | get id | str replace "…" ""
} else {
# Chinese characters break parsing, filter broken entries with `where source == winget`