Skip to main content

rl_lang/interpreter/stdlib/process/
mod.rs

1//! `std::process` - process management: args, env, cwd, exec, exit, pid, sleep.
2//!
3//! `exec` captures stdout and returns it as a string (trailing newline stripped).
4//! `exec_code` returns only the exit code as `int`.
5//! `exec_lines` returns stdout split into lines as `arr[string]`.
6//! Both `args` and `cwd` use `with_raw_function` since they take no rl arguments.
7//! `env` returns `null` (not an error) when the variable is not set.
8
9mod args;
10mod cwd;
11mod env;
12mod exec;
13mod exit;
14mod pid;
15mod sleep;
16
17use crate::interpreter::native::Module;
18
19pub const KEYWORDS: &[&str] = &[
20    "args",
21    "exit",
22    "env",
23    "cwd",
24    "set_cwd",
25    "pid",
26    "sleep",
27    "exec",
28    "exec_code",
29    "exec_lines",
30];
31
32pub fn module() -> Module {
33    Module::new("process")
34        .with_raw_function("args", args::std_args)
35        .with_function("exit", exit::std_exit)
36        .with_function("env", env::std_env)
37        .with_raw_function("cwd", cwd::std_cwd)
38        .with_function("set_cwd", cwd::std_set_cwd)
39        .with_raw_function("pid", pid::std_pid)
40        .with_function("sleep", sleep::std_sleep)
41        .with_function("exec", exec::std_exec)
42        .with_function("exec_code", exec::std_exec_code)
43        .with_function("exec_lines", exec::std_exec_lines)
44}