roc-lang / basic-cli

A basic Command-Line Interface platform
Universal Permissive License v1.0
88 stars 30 forks source link

Add `Env.platform` effect #211

Closed lukewilliamboswell closed 4 months ago

lukewilliamboswell commented 5 months ago

This will be helpful for build scripts which can use this instead of shelling out to another program like uname.

# Env.roc
ARCH : [X86, X64, ARM, AARCH64, OTHER Str]
OS : [LINUX, MACOS, WINDOWS, OTHER Str]

platform : Task {arch : ARCH, os: OS} *
app [main] { pf: platform "../platform/main.roc" }

import pf.Stdout
import pf.Task exposing [Task]
import pf.Env

main =
    platform = Env.platform!
    Stdout.line! "Running on $(Inspect.toStr platform)"
$ roc examples/test.roc
Running on {arch: AARCH64, os: MACOS}

Closes #203