mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 19:32:17 +00:00
25 lines
822 B
Text
25 lines
822 B
Text
app "env"
|
|
packages { pf: "cli-platform/main.roc" }
|
|
imports [pf.Stdout, pf.Env, pf.Task, pf.Program.{ Program }]
|
|
provides [main] to pf
|
|
|
|
main : Program
|
|
main =
|
|
Env.decode "EDITOR"
|
|
|> Task.await (\editor -> Stdout.line "Your favorite editor is \(editor)!")
|
|
|> Task.await (\{} -> Env.decode "SHLVL")
|
|
|> Task.await
|
|
(\lvl ->
|
|
when lvl is
|
|
1u8 -> Stdout.line "You're running this in a root shell!"
|
|
n ->
|
|
lvlStr = Num.toStr n
|
|
|
|
Stdout.line "Your current shell level is \(lvlStr)!")
|
|
|> Task.await (\{} -> Env.decode "LETTERS")
|
|
|> Task.await
|
|
(\letters ->
|
|
joinedLetters = Str.joinWith letters " "
|
|
|
|
Stdout.line "Your favorite letters are: \(joinedLetters)")
|
|
|> Program.quick
|