summaryrefslogtreecommitdiff
path: root/docs/std/env.md
diff options
context:
space:
mode:
authorZuhaitz <zuhaitz.zechhub@gmail.com>2026-01-22 23:30:21 +0000
committerGitHub <noreply@github.com>2026-01-22 23:30:21 +0000
commit3a4a72a38675893c3a1854d05c72b957a6bd9364 (patch)
tree91c79a71830c72f8cedfa2b051e4bab4037dc5a4 /docs/std/env.md
parent03df9c337355dc45a14e2c2fbe3276dfe890c68d (diff)
parent2a4edc7f2c9241ec7845cecadef850a1db45b3dd (diff)
Merge pull request #97 from Burnett01/feat/std-env-for-environment-variables
feat: New std library "env" for accessing the process environment
Diffstat (limited to 'docs/std/env.md')
-rw-r--r--docs/std/env.md66
1 files changed, 66 insertions, 0 deletions
diff --git a/docs/std/env.md b/docs/std/env.md
new file mode 100644
index 0000000..09ece60
--- /dev/null
+++ b/docs/std/env.md
@@ -0,0 +1,66 @@
+# 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
+```
+
+### unset
+
+Unsets an existing env-var
+
+```zc
+fn unset(name: string) -> EnvRes
+```
+
+---
+
+Check the ``examples`` folder for more.