Running a program

ecko program.ecko          # the usual form
ecko run program.ecko      # explicit, identical behaviour
ecko -e 'print(1 + 1)'     # code given on the command line
ecko - < program.ecko      # the program read from stdin

The bare form exists because running a file is the common case and should not need a subcommand. run is there for scripts and wrappers where an explicit verb reads better.

-e is for checking one call without a scratch file, like python -c. Both -e and - behave like a file run in every other way: the same check before the first line, the same exit status, and everything after the code or the - is the program's arguments. Imports and ecko.json are read from the working directory, and errors name the source -e or <stdin>.

What happens before your code

ecko runs ecko check over the program first and refuses to start if there is an error-level finding: an undefined name, a call with the wrong number of arguments, a match that is not exhaustive, a credential used without reveal. Warnings are printed and do not stop the run.

A file that does not parse never starts either, and every syntax error in it is printed with its source line, not only the first.

This is deliberate. A dynamically typed language normally discovers a typo on line 400 after doing 399 lines of work, some of it irreversible. Ecko finds it before the first line executes.

Arguments

Everything after the file is passed to the program, not to ecko:

ecko report.ecko --format json data.csv

Read them with std.os, or parse them declaratively with the cli package:

import std.os
print(os.args())  # [--format, json, data.csv]

Exit status

0 on success. Non-zero when the program raises an uncaught error, when check finds an error-level problem, or when the file cannot be read. An uncaught error prints the message, the source line that raised it and a call stack, each location as file:line:col - including one inside an imported file.

Reloading on change

For a server or a script you are iterating on, ecko dev re-runs the file whenever it changes.

A note on ai

No configuration is required. Without a provider, ai runs in mock mode, so any program in this documentation runs as written. Set ECKO_AI_API_KEY, and add --provider or --model before the file (see Global flags) to pick a provider for one run.