git clone https://garage44.eu/jeroen/pinnacle.git.. /programs/frits/terminal.frits
// What a Frits script run from Pinnacle's terminal can do (`frits run`).
// Its output is records, as every command's is: text, tables, progress and
// questions, which the terminal draws. A script names the effects it uses on
// its first line, and `frits check` lists them before anything runs.
// The terminal the script was started from.
effect Console {
// A line of text in the terminal's output.
fn print(text: Str)
// A table under named columns; the terminal picks the widths.
fn table(columns: List<Str>, rows: List<List<Str>>)
// How far a piece of work is: one bar per script, updated in place.
fn progress(done: Int, total: Int, label: Str)
// Asks whoever is at the terminal for a line of text, and waits.
fn ask(prompt: Str) -> Str
// Asks for one of the options, and waits.
fn choose(prompt: Str, options: List<Str>) -> Str
// Asks yes or no, and waits.
fn confirm(prompt: Str) -> Bool
// The words after the script on the command line.
fn args() -> List<Str>
}
// Files on this device. A path without a disk (`notes/todo`) is on the data
// disk: `data:/notes/todo`.
effect Files {
// The file's text.
fn read(path: Str) -> Result<Str, Str>
// Replaces the file with `text`, making it if it is not there.
fn write(path: Str, text: Str) -> Result<Unit, Str>
// Adds `text` at the file's end, making it if it is not there.
fn append(path: Str, text: Str) -> Result<Unit, Str>
// The names in a folder; a folder's name ends in `/`.
fn list(path: Str) -> Result<List<Str>, Str>
// Whether there is a file or folder at `path`.
fn exists(path: Str) -> Bool
// Removes the file, or the empty folder.
fn remove(path: Str) -> Result<Unit, Str>
}
// Time.
effect Clock {
// Seconds since 1970 (UTC); 0 when the device has no clock.
fn now() -> Int
// Milliseconds since the device started.
fn uptime() -> Int
// Waits `seconds` before going on.
fn wait(seconds: Float)
}
// The internet.
effect Net {
// The body of `url` (http or https), fetched with GET. Text from
// elsewhere is untrusted: check it before acting on it.
fn get(url: Str) -> Result<Untrusted<Str>, Str>
}
// Run once, when the script starts.
event main()