Nomsu v7.0.0 API
The Nomsu API.
This page has a listing of the Nomsu API, automatically generated using this script. Click on an action’s name to see its definition and a link to where it’s defined in the codebase. This API documentation does not include complete descriptions of what each action does, but hopefully the actions are descriptively-enough named, and have readable-enough source code that it will be easy to understand what they do.
Nomsu v7.0.1 API
lib/base64/init.nom
-
base64 $str
$str, base64 encode $str, $str base64] all mean: [base64 $chars = [] $i in (1 to #$str by 3): for $bytes = [=lua "\$str:byte(\$i, \($i + 2))"] $chars, add $b64_chars.((($bytes.1 & 252) >> 2) + 1) $bytes is: if #3: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) $chars, add $b64_chars.((($bytes.2 & 15) << 2) + (($bytes.3 & 192) >> 6) + 1) $chars, add $b64_chars.(($bytes.3 & 63) + 1) 2: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) $chars, add $b64_chars.((($bytes.2 & 15) << 2) + 1) $chars, add "=" 1: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + 1) $chars, add "=" $chars, add "=" $chars, joined) return (
-
base64 encode $str
$str, base64 encode $str, $str base64] all mean: [base64 $chars = [] $i in (1 to #$str by 3): for $bytes = [=lua "\$str:byte(\$i, \($i + 2))"] $chars, add $b64_chars.((($bytes.1 & 252) >> 2) + 1) $bytes is: if #3: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) $chars, add $b64_chars.((($bytes.2 & 15) << 2) + (($bytes.3 & 192) >> 6) + 1) $chars, add $b64_chars.(($bytes.3 & 63) + 1) 2: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) $chars, add $b64_chars.((($bytes.2 & 15) << 2) + 1) $chars, add "=" 1: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + 1) $chars, add "=" $chars, add "=" $chars, joined) return (
-
$str base64
$str, base64 encode $str, $str base64] all mean: [base64 $chars = [] $i in (1 to #$str by 3): for $bytes = [=lua "\$str:byte(\$i, \($i + 2))"] $chars, add $b64_chars.((($bytes.1 & 252) >> 2) + 1) $bytes is: if #3: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) $chars, add $b64_chars.((($bytes.2 & 15) << 2) + (($bytes.3 & 192) >> 6) + 1) $chars, add $b64_chars.(($bytes.3 & 63) + 1) 2: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) $chars, add $b64_chars.((($bytes.2 & 15) << 2) + 1) $chars, add "=" 1: $chars, add $b64_chars.((($bytes.1 & 3) << 4) + 1) $chars, add "=" $chars, add "=" $chars, joined) return (
-
chr $
$) means (=lua "string.char(\$)") (chr
-
decode base64 $str
$str, $str base64 decoded, base64 decode $str] all mean: [decode base64 $chars = [] $i in (1 to #$str by 4): for $indices = [: for $j in ($i to ($i + 3)): add $reverse_b64.($str, character $j)] $chars, add (chr (($indices.1 << 2) + (($indices.2 & 48) >> 4))) $str, character ($i + 2)) == "="): stop if (($chars, add (chr ((($indices.2 & 15) << 4) + (($indices.3 & 60) >> 2))) $str, character ($i + 3)) == "="): stop if (($chars, add (chr ((($indices.3 & 3) << 6) + $indices.4)) $chars, joined) return (
-
$str base64 decoded
$str, $str base64 decoded, base64 decode $str] all mean: [decode base64 $chars = [] $i in (1 to #$str by 4): for $indices = [: for $j in ($i to ($i + 3)): add $reverse_b64.($str, character $j)] $chars, add (chr (($indices.1 << 2) + (($indices.2 & 48) >> 4))) $str, character ($i + 2)) == "="): stop if (($chars, add (chr ((($indices.2 & 15) << 4) + (($indices.3 & 60) >> 2))) $str, character ($i + 3)) == "="): stop if (($chars, add (chr ((($indices.3 & 3) << 6) + $indices.4)) $chars, joined) return (
-
base64 decode $str
$str, $str base64 decoded, base64 decode $str] all mean: [decode base64 $chars = [] $i in (1 to #$str by 4): for $indices = [: for $j in ($i to ($i + 3)): add $reverse_b64.($str, character $j)] $chars, add (chr (($indices.1 << 2) + (($indices.2 & 48) >> 4))) $str, character ($i + 2)) == "="): stop if (($chars, add (chr ((($indices.2 & 15) << 4) + (($indices.3 & 60) >> 2))) $str, character ($i + 3)) == "="): stop if (($chars, add (chr ((($indices.3 & 3) << 6) + $indices.4)) $chars, joined) return (
lib/commandline/init.nom
-
command line program with $args $body
$args $body) parses as: (command line program with $args) means $body) external ((run with if (this file was run directly): run with (the command line arguments)
-
usage $
$) means: (usage "Usage: \$" say 1 exit
lib/file_hash/init.nom
-
hash $
$) means: (hash $hash = (=lua "\$hashlib.new('sha1'):final(\$)") $hash) return (base64
-
hash $
$) means: (hash $bytes = ($, bytes) $hash = ($bytes.1 << 7) $i in (2 to #$bytes): for $hash = ((1000003 * $hash) ~ $bytes.$i) $hash = ($hash ~ #$bytes) "\$hash" return
-
file with hash $hash
$hash) means: (file with hash $filename in (files for "."): for $contents = (read file $filename) $file_hash = (hash $contents) $file_hash == $hash): if ($filename return
-
hash of file $filename
$filename) parses as (hash (read file $filename)) (hash of file
lib/filesystem/init.nom
-
files for $path
$path) means: (files for $files = (=lua "Files.list(\$path)") $files: if $files = (List $files) $files return
-
write to file $filename $text
[$filename $text, to file $filename write $text write to file $text to file $filename write ] all mean:$filename != "stdin"): unless ("Cannot write to stdin" fail > (" lua local file = io.open(\$filename, 'w') file:write(\$text) file:close() ")
-
to file $filename write $text
[$filename $text, to file $filename write $text write to file $text to file $filename write ] all mean:$filename != "stdin"): unless ("Cannot write to stdin" fail > (" lua local file = io.open(\$filename, 'w') file:write(\$text) file:close() ")
-
write $text to file $filename
[$filename $text, to file $filename write $text write to file $text to file $filename write ] all mean:$filename != "stdin"): unless ("Cannot write to stdin" fail > (" lua local file = io.open(\$filename, 'w') file:write(\$text) file:close() ")
-
source lines of $tree
$tree) means: (source lines of $source = ($tree.source if ($tree is syntax tree) else $tree) $file = (read file $source.filename) return [:$ in for $file, line number at $source.start) to ($file, line number at $source.stop) (..: $file, line $) add ("\n" ], joined with
lib/progressbar/init.nom
-
$x / $w progress bar
$x / $w progress bar) means: ($x = ($x clamped between 0 and $w) $(COLOR ENABLED): if $bits = [" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"] $middle = ("" if ($x == $w) else $bits.(1 + (floor (#$bits * ($x mod 1))))) (" return \(reset color)[\(green)\($bits, last, rep (floor $x))\($middle)\ ..\(" ", rep ($w - ((floor $x) + 1)))\(reset color)] ") ..else: ### Probably not unicode support either: "[\("#", rep ($x, rounded down))\("-", rep ($w - ($x, rounded down)))]" return
-
$w wide $ progress bar
$w wide $ progress bar) means (($ * $w) / $w progress bar) (
lib/shell/init.nom
-
at $callsite =sh $cmd
$callsite =sh $cmd) means: (at $f = ($io.popen $cmd) $contents = ($f, read "*a") $ok, $return_type, $return] = ($f, close) [$ok: unless $return_type == "exit"): if ($callsite fail at "Command failure: Command `\($cmd)` failed with exit code \$return" ..else: $callsite fail at "Command failure: Command `\($cmd)` was terminated by signal \$return" $contents return
-
at $callsite sh> $cmd
$callsite sh> $cmd) means: (at $ok, $return_type, $return] = ($os.execute $cmd) [$ok: unless $return_type == "exit"): if ($callsite fail at "Command failure: Command `\($cmd)` failed with exit code \$return" ..else: $callsite fail at "Command failure: Command `\($cmd)` was terminated by signal \$return"
-
=sh $cmd
=sh $cmd) compiles to \(at \("Text" tree with "\($cmd.source)") =sh \$cmd) (
-
sh> $cmd
> $cmd) compiles to \(at \("Text" tree with "\($cmd.source)") sh> \$cmd) (sh