core:cli
CLI helpers: println, eprintln, args, env, exit, etc. For raw
WASI CLI interfaces, use wasi:cli directly.
Synopsis
println("Hello, Wado!");
for let arg of args() {
println(`arg: ${arg}`);
}
if let Some(home) = env("HOME") {
println(`HOME=${home}`);
}
Functions
pub fn write_to_stream(tx: StreamWritable<u8>, message: String, add_newline: bool)
Writes a string to a StreamWritable<u8> with an optional newline, then drops it.
pub fn println(message: String) with Stdout
Prints a line to stdout (adds newline).
pub fn eprintln(message: String) with Stderr
Prints a line to stderr (adds newline).
pub fn print(message: String) with Stdout
Prints to stdout without a trailing newline.
pub fn eprint(message: String) with Stderr
Prints to stderr without a trailing newline.
pub fn print_bytes(data: List<u8>) with Stdout
Writes raw bytes to stdout.
pub fn env(name: String) -> Option<String> with Environment
Returns the value of an environment variable by name.
pub fn args() -> List<String> with Environment
The command-line arguments, after the program name.
pub fn program_name() -> Option<String> with Environment
The name the program was started as, such as the path wado run was given,
never the runner. None when the host gives no command line.
pub fn cwd() -> Option<String> with Environment
Returns the current working directory.
pub fn exit_success() -> ! with Exit
Exits with success (code 0).
pub fn exit_error() -> ! with Exit
Exits with an error.
pub fn exit(code: u8) -> ! with Exit
Exits with a specific status code.
pub fn log_stdout(message: String)
#[ambient]
Logs a message with newline to stdout (ambient, no effect required). Uses builtin::call_indirect__ to bypass the effect system — this is intentional for logging/debugging which must work without effects.
pub fn log_stderr(message: String)
#[ambient]
Logs a message with newline to stderr (ambient, no effect required). Uses builtin::call_indirect__ to bypass the effect system — this is intentional for logging/debugging which must work without effects.
