WasiCli
1 type6 functionsReading and writing a command-line program's standard streams, its
arguments, its environment variables, and its exit, for a WASI preview1
host. The wasip2 package's WasiCli, preloaded on the component target
instead, has print, args, env and exit, with exit reaching the host
as success or failure only.
Types
Result
Shorthand for [Ok(a) | Err(e)], the variant this module's fallible
functions return.
Functions
Writes the string to stdout, exactly as it is: no newline is added.
readAll
Everything left on stdin, read to the end of input.
readLine
The next line of stdin, without its \n or \r\n. An empty line is
Ok(""), and a closed stdin is Err(EndOfInput), so a loop can tell the two
apart. A last line with no terminator is still Ok; the end of input is
reported on the call after it.
exit
Stop the program with code as its exit status. It does not return, so
its result is any type the call stands in for.
args
The program's arguments, starting with the program's own path as the host gives it.
env
The value of the environment variable name, everything after the first
= of its entry, or Err(NotFound) when the environment has none.