diff --git a/nothing.nu b/nothing.nu new file mode 100644 index 0000000..914d3a3 --- /dev/null +++ b/nothing.nu @@ -0,0 +1,24 @@ +# This checks the -f switch to see if it was supplied +# and tests the new $nothing variable +def nada [ + --flat(-f) +] { + if $flat == $nothing { + echo $true + } { + echo $false + } +} + +# This shows an alternate way to check for nothing +def nada2 [ + --flat(-f) +] { + let flat = $(= $flat | empty?) + + if $flat { + echo $true + } { + echo $false + } +} \ No newline at end of file diff --git a/stdlib_candidate/logging.nu b/stdlib_candidate/logging.nu new file mode 100644 index 0000000..734f84a --- /dev/null +++ b/stdlib_candidate/logging.nu @@ -0,0 +1,6 @@ +# This is a first attempt and some type of logging +def log [message:any] { + let now = $(date now | date format '%Y%m%d_%H%M%S.%f') + let mess = $(build-string $now '|DBG|' $message $(char newline)) + echo $mess | autoview +} \ No newline at end of file diff --git a/stdlib_candidate/print.nu b/stdlib_candidate/print.nu index d64bb55..de25bba 100644 --- a/stdlib_candidate/print.nu +++ b/stdlib_candidate/print.nu @@ -41,22 +41,29 @@ def print2 [ } } +# Bring in the logging command +source logging.nu + # A print command that concatenates arguments together with an optional separator. # This print command will also concatenate tables like [1 2 3] as well as most other primitives # since the str from command has been updated with wider support. def print3 [ --separator(-s):any # Optional separator (not yet flagged as optional?) - --flat(-f) # If tables are found, flatten them + --flat(-f) # If tables are found, flatten them ...rest # All of the parameters ] { let sep_empty = $(= $separator | empty?) let num_of_rest = $(echo $rest | count) + let flat = $(= $flat | empty?) echo $rest | each --numbered { if $sep_empty { + log 'sep is empty' if $(echo $it.item | count) > 1 && $flat { + log 'flatten please' let flatter = $(echo $it.item | flatten | str from | str collect) build-string $flatter } { + log 'no flat' build-string $it.item } } {