Calling ela
In the terminalela --spec calling-ela
Hand ela the script on stdin, in a here-document with its marker quoted: <<'EOF'. The calling
shell then passes every line through as written, so ela's quotes, its $name and its
backslashes need no escaping.
ela <<'EOF'errors = $(grep -c 'error' app.log)release = re.match(`^v\d+\.\d+$`, "v1.2")echo "errors: $errors, a release tag: $release"EOF
- A program ela has no words for runs as a command, as at any shell:
make ci,git status,kubectl get pods. ela -c 'make ci'runs one command.-ctakes the code as one argument, so it breaks at the first'in the code:ela -c 'msg = 'ready''reaches ela asmsg = readyand stops withbare word 'ready' in an expression. A here-document has no such limit.- To ask whether a program is there, use
path.program. It prints nothing and gives the program's full path, or"":if path.program("docker") != "". - A script an agent runs has no terminal, so the prompts of the
askpackage (ask.line,ask.yes,ask.choose) andwith screenstop it with an error naming the question. Write a script that takes the answer as an argument,$args[0], or a flag, and asks only when none was given (ela --spec ask).
ela reads the whole script before it runs a line. A mistake anywhere stops it before the first line runs, so a half-done run never needs cleaning up. Here line 1 never prints:
$ ela <<'EOF'echo "starting the deploy"for host in ["web1", "web2"] echo "deploying to $host"end forif len($hosts > 0 echo "done"end ifEOFstdin:6:5: error: expected ')' to close the argument list, got 'echo'
- Before the first line, ela parses the whole script, finds every file it imports, and checks
that every call names a proc there is:
x = str.starts_with($s, "a")late in a script stops it before line 1 withno proc str.starts_with; str has …, and so does a call to a proc that neither the script nor its imports declare.ela --check -reports each one. - An error names its place:
stdin:line:colfor code on stdin,-c:line:colforela -c, andfile:line:colfor a script. - ela exits with the code of the command that failed, or 1.
(ela --spec commands, ela --spec paths-and-directories)