Commands
In the terminalela --spec commands
- Commands are typed bare, as in Bash:
git statusruns. - A bare command runs and waits for completion.
- Outside quotes,
\makes the next character itself, as in Bash:echo c\*.txtpassesc*.txt, andls \.h*lists the hidden files whose names start withh(PACKAGES.md, Paths and directories, for globs). echois ela's own: it writes its words a space apart and a newline, which-nleaves out, with no process started. It has no-e, since a string in double quotes holds its escapes already:echo "name\tsize". It takes redirects and stands in a pipeline as any command does, andwarnwrites the same to stderr (SHELL.md, Built-ins). There is noprint, which--lintwarns of, as mailcap'sprintprogram opens a file to print it;printfis the system's program. To stop the script with a message,fail "no config in $dir"writes it to stderr and exits 1 (fail).
echo "deploying $host"echo -n "waiting... "echo "$name\t$size" >> report.tsvecho $text | sha256sum
echo prints any value #
echo prints a list, a map, a struct or a table as well as text, numbers and booleans, in ela's
own form, the one a value typed alone at the prompt prints in, so what it prints can be pasted
back into a script. Text inside a value is quoted, so "1" and 1 differ.
- A value stays on one line when it fits the width: the terminal's when
echowrites to it alone, else 100 columns, into a file, a pipe or a$( ), so a script writes the same file every time. Past it, a list or a map breaks one item a line, indented four spaces, each item laid out by the same rule. - A value is never cut: a list of 9,800 paths prints all 9,800, as
catprints a big file. A value typed alone at the prompt prints the same way. - A list prints its form too,
["ela", "amber-lib"], soecho $xnever depends on what kind of valuexholds. Every other command still takes a list's items as its arguments, andstr.joinmakes the words:echo ${str.join($names, " ")}.ela --lintpointsecho $lof a list it knows tostr.join. - A table prints as aligned columns under a header row of its names.
- A word that starts with a name or a package's
pkg.nameglued to(is a call, its value printed asecho $xprints one:echo len($hosts),echo list.head($hosts, 2),echo plan($target). ela's call parser reads it to its matching), spaces, commas and lines inside, and checks it before line 1 as any call: a name no proc has isno proc named …. An index or a field glued to the)is the call's,echo list.head($hosts, 2)[0], and text glued after it is the word's,echo len($done)%. After the call,echo's words go on as always:echo len($hosts) + 1prints3 + 1. Onlyechoreads a word as a call:warnand every other command take their words as text, and a call in one is${len($hosts)}. A$( )runs a command, and a call is none, soecho $(len($hosts))is an error that namesecho len($hosts). - Only
echotakes a map: any other command still refuses one, and text joined with a map,"got $m", is still an error.json.encodeand the other data packages'encodemake text in a format.
names = ["ela", "amber-lib"]echo $names # ["ela", "amber-lib"]echo ${str.join($names, " ")} # ela amber-libls $names # ls ela amber-libecho len($names) # 2echo "deps:" list.head($names, 1) "first" # deps: ["ela"] firstsmall = {"name": "ela", "size": 1204}echo $small # {"name": "ela", "size": 1204}echo map.keys($small) > keys.txt # ["name", "size"] into keys.txt
{ "name": "ela", "deps": ["amber-lib", "amber-json", "amber-toml", "odin-web"], "paths": {"build": "/home/ada/ela/build", "dist": "/home/ada/ela/dist"},}