diff options
| author | Steven <burnett@posteo.de> | 2026-01-22 22:57:14 +0000 |
|---|---|---|
| committer | Steven <burnett@posteo.de> | 2026-01-22 22:57:14 +0000 |
| commit | f4cd3cd10428af1a248c3a8bfe7b99332f072fbf (patch) | |
| tree | ea17fbcc875b425738a651011b94ec41b7b2c2e1 /docs/std/env.md | |
| parent | ed4bbfd8cf4a72fdf4a5d6cba94d537cab340356 (diff) | |
feat: New std library "env" for accessing the process environment
Diffstat (limited to 'docs/std/env.md')
| -rw-r--r-- | docs/std/env.md | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/docs/std/env.md b/docs/std/env.md new file mode 100644 index 0000000..b4ff5dd --- /dev/null +++ b/docs/std/env.md @@ -0,0 +1,74 @@ +# Standard Library: Env (`std/env.zc`) + +`Env` is a Zen-C library for accessing the environment of the process environment. + +## Usage + +```zc +import "std/env.zc" + +fn main() { + Env::set("HELLO", "world"); + + var hello = Env::get("HELLO"); + + if (hello.is_some()) { + println "Hello {hello.unwrap()}"; + } +} +``` + +## Enum + +```zc +enum EnvRes { + ERR, + OK, +} +``` + +## Methods + +### get + +Retrieves the env-var as borrowed string (char *) (no alloc) + +```zc +fn get(name: string) -> Option<string> +``` + +### get_dup + +Retrieves the env-var as caller-owned String() (heap alloc) + +```zc +fn get_dup(name: string) -> Option<String> +``` + +### set + +Sets an env-var variable + +```zc +fn set(name: string, value: string) -> EnvRes +``` + +### set_overwrite + +Overwrites an exisiting env-var / creates it if it doesn't exist + +```zc +fn set_overwrite(name: string, value: string) -> EnvRes +``` + +### unset + +Unsets an existing env-var + +```zc +fn unset(name: string) -> EnvRes +``` + +--- + +Check the ``examples`` folder for more. |
