Skip to content

Commit

Permalink
Switch to 'and' and 'or' (#322)
Browse files Browse the repository at this point in the history
* Switch to 'and' and 'or'

* oops
  • Loading branch information
sophiajt committed Dec 7, 2022
1 parent fe5c307 commit 6f9d625
Show file tree
Hide file tree
Showing 28 changed files with 104 additions and 101 deletions.
2 changes: 1 addition & 1 deletion before_v0.60/coloring/gradient.nu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let stamp = 'Nu'
seq 0 $height | each {
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} {
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
Expand Down
2 changes: 1 addition & 1 deletion before_v0.60/fehbg.nu
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def select_random [] { shuffle | first }

# List all images in a directory and all its subdirectories
def list_images [dir] {
ls (build-string $dir /**/*) | where type == File | where name =~ jpg || name =~ jpeg || name =~ tif || name =~ tiff
ls (build-string $dir /**/*) | where type == File | where name =~ jpg or name =~ jpeg or name =~ tif or name =~ tiff
}

# Set the caption text (just filename for now)
Expand Down
2 changes: 1 addition & 1 deletion before_v0.60/fun/life.nu
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def alive [x-pos: int, y-pos: int, $grid] {

let $curr = ($data | nth ($x-pos + $y-pos * $width))

if ($total == 3) || ($total == 2 && $curr) {
if ($total == 3) or ($total == 2 and $curr) {
$true
} {
$false
Expand Down
24 changes: 12 additions & 12 deletions before_v0.60/fun/nyancat.nu

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions before_v0.60/language/playground/lib.nu
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def play [
if $is_tag_empty {
do $block
} {
if $tag == $nu.env.REJECT && $should_run_all {
if $tag == $nu.env.REJECT and $should_run_all {
$" ($topic) ... (ansi yellow)skipped(ansi reset) (char newline)"
} { do $block }
}
Expand All @@ -43,7 +43,7 @@ def expect [

$values.0 == $values.1
}
| all? $it) && (($actual | get | length) == ($to-be | get | length));
| all? $it) and (($actual | get | length) == ($to-be | get | length));

let line = (if $true == $are_equal {
$"(ansi green)ok(ansi reset)(char newline)"
Expand Down
2 changes: 1 addition & 1 deletion before_v0.60/lint_directories.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# - 1.0.1 is a valid directory name.
# - yeah_whatever_linter is not a valid directory name.
def ls-incorrect-dirs [] {
ls | where type == 'Dir' && name != 'scripts'| match -v name '(\d+\.){2,}\d$'
ls | where type == 'Dir' and name != 'scripts'| match -v name '(\d+\.){2,}\d$'
}
let incorrect_count = (ls-incorrect-dirs | length);
if $incorrect_count > 0 {
Expand Down
2 changes: 1 addition & 1 deletion before_v0.60/make_release/this_week_in_nu_weekly.nu
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def do-work [] {
let week_num = (seq date -b '2019-08-23' -n 7 | length)
$"# This week in Nushell #($week_num)(char nl)(char nl)"

if ($nu.env | select GITHUB_USERNAME | empty?) || ($nu.env | select GITHUB_PASSWORD | empty?) {
if ($nu.env | select GITHUB_USERNAME | empty?) or ($nu.env | select GITHUB_PASSWORD | empty?) {
echo 'Please set GITHUB_USERNAME and GITHUB_PASSWORD in $nu.env to use this script'
} {
do-work | str collect
Expand Down
2 changes: 1 addition & 1 deletion before_v0.60/prompt/git_status_prompt.nu
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def git-branch-icon [] {
$"|(ansi green)($branch)(ansi reset):(ansi green)(ansi reset)"
} {
let modified2 = (do -i { git status --porcelain } | split row "\n" | str substring [0 1])
let branch-colour = (if (echo $modified2 | each { $it in [A M R C D] } | reduce { $it || $acc }) {
let branch-colour = (if (echo $modified2 | each { $it in [A M R C D] } | reduce { $it or $acc }) {
"yellow"
} {
"red"
Expand Down
6 changes: 3 additions & 3 deletions before_v0.60/stdlib_candidate/print.nu
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def print3 [
$rest | each --numbered { |param|
if $sep_empty {
#log 'sep is empty'
if (echo $param.item | length) > 1 && $flat {
if (echo $param.item | length) > 1 and $flat {
#log 'flatten please'
let flatter = ($param.item | flatten | into string | str collect)
$flatter
Expand All @@ -68,14 +68,14 @@ def print3 [
}
} {
if $num_of_rest > ($param.index + 1) {
if ($param.item | length) > 1 && $flat {
if ($param.item | length) > 1 and $flat {
let flatter = ($param.item | flatten | into string | str collect $separator)
$"($flatter)($separator)"
} {
$"($param.item)($separator)"
}
} {
if ($param.item | length) > 1 && $flat {
if ($param.item | length) > 1 and $flat {
let flatter = ($param.item | flatten | into string | str collect $separator)
$flatter
} {
Expand Down
8 changes: 4 additions & 4 deletions before_v0.60/weather/get-weather.nu
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def get_weather [
let is_loc_empty = ($locIdx | empty?)
let is_units_empty = ($units | empty?)

let no_loc_no_unit = ($is_loc_empty == $true && $is_units_empty == $true)
let no_loc_with_unit = ($is_loc_empty == $true && $is_units_empty == $false)
let with_loc_no_unit = ($is_loc_empty == $false && $is_units_empty == $true)
let with_loc_with_unit = ($is_loc_empty == $false && $is_units_empty == $false)
let no_loc_no_unit = ($is_loc_empty == $true and $is_units_empty == $true)
let no_loc_with_unit = ($is_loc_empty == $true and $is_units_empty == $false)
let with_loc_no_unit = ($is_loc_empty == $false and $is_units_empty == $true)
let with_loc_with_unit = ($is_loc_empty == $false and $is_units_empty == $false)

# This is a cautionary tale, the commented out code below is returning
# and autoview is viewing the data, so no structured data is being returned.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/gradient-autoview.nu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let stamp = 'Nu'
seq 0 $height | par-each { # create these in parallel
let row_data = (seq 0 $width | each { |col|
let fgcolor = 2 + 2 * $col
if $fgcolor > $stamp_start && $fgcolor < $stamp_end {
if $fgcolor > $stamp_start and $fgcolor < $stamp_end {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/gradient.nu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let stamp = 'Nu'
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/gradient_benchmark.nu
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
Expand All @@ -37,7 +37,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
Expand All @@ -56,7 +56,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
Expand All @@ -77,7 +77,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"($ansi1)($fgcolor)m($stamp)($ansi2)"
} else {
$"($ansi1)($fgcolor)m(char sp)($ansi2)"
Expand All @@ -96,7 +96,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = 2 + 2 * $col
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
Expand All @@ -115,7 +115,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = 2 + 2 * $col
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
Expand All @@ -134,7 +134,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | par-each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = 2 + 2 * $col
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/gradient_benchmark_no_check.nu
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
Expand All @@ -38,7 +38,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
Expand All @@ -57,7 +57,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
Expand All @@ -78,7 +78,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = (iter_inc 2 2 $col)
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"($ansi1)($fgcolor)m($stamp)($ansi2)"
} else {
$"($ansi1)($fgcolor)m(char sp)($ansi2)"
Expand All @@ -97,7 +97,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = 2 + 2 * $col
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
Expand All @@ -116,7 +116,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = 2 + 2 * $col
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
Expand All @@ -135,7 +135,7 @@ if ($is_release | str downcase | str trim) == "y" {
seq 0 $height | par-each { |row|
let row_data = (seq 0 $width | each { |col|
let fgcolor = 2 + 2 * $col
if $fgcolor > 200 && $fgcolor < 210 {
if $fgcolor > 200 and $fgcolor < 210 {
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
Expand Down
16 changes: 8 additions & 8 deletions coloring/hl.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ export def combine [txt: string, fg: record, bg: record] {
txt: $txt,
fg: $fg.fg,
bg: $bg.fg,
bli: ($fg.bli || $bg.bli),
bol: ($fg.bol || $bg.bol),
dim: ($fg.dim || $bg.dim),
hid: ($fg.hid || $bg.hid),
ita: ($fg.ita || $bg.ita),
rev: ($fg.rev || $bg.rev),
stk: ($fg.stk || $bg.stk),
und: ($fg.und || $bg.und)
bli: ($fg.bli or $bg.bli),
bol: ($fg.bol or $bg.bol),
dim: ($fg.dim or $bg.dim),
hid: ($fg.hid or $bg.hid),
ita: ($fg.ita or $bg.ita),
rev: ($fg.rev or $bg.rev),
stk: ($fg.stk or $bg.stk),
und: ($fg.und or $bg.und)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cool-oneliners/git_gone.nu
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# gently try to delete merged branches, excluding the checked out one
git branch --merged | lines | where $it !~ '\*' | str trim | where $it != 'master' && $it != 'main' | each { |it| git branch -d $it }
git branch --merged | lines | where $it !~ '\*' | str trim | where $it != 'master' and $it != 'main' | each { |it| git branch -d $it }
12 changes: 6 additions & 6 deletions custom-completions/auto-generate/parse-fish.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 != "" {
Expand All @@ -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
Expand 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
})
)
Expand Down
14 changes: 7 additions & 7 deletions custom-completions/winget/winget-completions.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)"
Expand All @@ -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`
Expand All @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion fehbg.nu
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def list-images [dir: path] {
ls $"($dir)/**/*" |
where type == file |
str downcase name |
where name =~ jpg || name =~ jpeg || name =~ tif || name =~ tiff || name =~ png
where name =~ jpg or name =~ jpeg or name =~ tif or name =~ tiff or name =~ png
}

# Set the caption text (just filename for now)
Expand Down

0 comments on commit 6f9d625

Please sign in to comment.