shape-runtime 0.3.0

Bytecode compiler, builtins, and runtime infrastructure for Shape
Documentation
/// @module std::core::env
/// Environment Variables and System Information
///
/// Access environment variables, command-line arguments, working directory,
/// and system information (OS, architecture).
///
/// # Example
///
/// ```shape
/// use std::core::env
///
/// let home = env.get("HOME")
/// match home {
///     Some(path) => print(f"Home: {path}")
///     None => print("HOME not set")
/// }
/// print(f"OS: {env.os()}, Arch: {env.arch()}")
/// ```

/// Get the value of an environment variable, or none if not set.
///
/// # Arguments
///
/// * `name` - Environment variable name
///
/// # Returns
///
/// `Some(value)` if the variable is set, `None` otherwise.
///
/// # Example
///
/// ```shape
/// let path = env.get("PATH")
/// ```
pub builtin fn get(name: string) -> _;

/// Check if an environment variable is set.
///
/// # Arguments
///
/// * `name` - Environment variable name
///
/// # Returns
///
/// `true` if the variable exists, `false` otherwise.
///
/// # Example
///
/// ```shape
/// if env.has("API_KEY") { print("API key configured") }
/// ```
pub builtin fn has(name: string) -> bool;

/// Get all environment variables as a HashMap.
///
/// # Returns
///
/// A HashMap mapping variable names to their values.
///
/// # Example
///
/// ```shape
/// let vars = env.all()
/// ```
pub builtin fn all() -> HashMap<string, string>;

/// Get command-line arguments as an array of strings.
///
/// # Returns
///
/// An array of strings, where the first element is the binary name.
///
/// # Example
///
/// ```shape
/// let args = env.args()
/// ```
pub builtin fn args() -> Array<string>;

/// Get the current working directory.
///
/// # Returns
///
/// The absolute path of the current working directory.
///
/// # Example
///
/// ```shape
/// let cwd = env.cwd()
/// ```
pub builtin fn cwd() -> string;

/// Get the operating system name (e.g. linux, macos, windows).
///
/// # Returns
///
/// A string identifying the operating system.
///
/// # Example
///
/// ```shape
/// let os = env.os()  // "linux", "macos", or "windows"
/// ```
pub builtin fn os() -> string;

/// Get the CPU architecture (e.g. x86_64, aarch64).
///
/// # Returns
///
/// A string identifying the CPU architecture.
///
/// # Example
///
/// ```shape
/// let arch = env.arch()  // "x86_64" or "aarch64"
/// ```
pub builtin fn arch() -> string;