@Brian Carroll thanks a lot for the recommendation. By gluing together few examples I managed to put together something that should give me a list of files, but because I don't really know what I'm doing yet - it fails. I want to figure it out on my own but I'm not really sure where can I find all the error types in the task result section:
app "file-read"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" }
imports [
pf.Stdout,
pf.Task.{ Task },
pf.Path,
pf.Env,
pf.Dir,
]
provides [main] to pf
main =
task =
cwd <- Env.cwd |> Task.await
dirEntries <- Dir.list cwd |> Task.await
contentsStr = Str.joinWith (List.map dirEntries Path.display) "\n "
Stdout.line contentsStr
Task.attempt task \result ->
when result is
Ok {} -> Stdout.line "Success"
Err err ->
msg =
when err is
IOError _ _ -> "Error reading dir"
DecodeError -> "Decode Error"
_ -> "there was an error!"
Stdout.line msg
A message was moved here from #introductions > introductions by Richard Feldman.
@Jakub welcome! :wave:
would you mind printing out the error you're seeing?
I'm getting there was an error!
Debian GNU/Linux 11
I'm using mcr.microsoft.com/devcontainers/base:bullseye
in VSCode DevContainers. BTW I was thinking about creating dev Docker image in case people would like to try out Roc without having to go through the installation process. Would it add any value / help anyone?
and one more thing, the code above is a clumsy copy / paste of: https://raw.githubusercontent.com/roc-lang/roc/main/examples/cli/file.roc - I tried to go backwards to get to the shortest code that could possibly work. Maybe I'm importing a wrong platform...
Yeah so Dir.list
on basic cli is currently unimplemented and is returning an error tag rather than crashing or panicking in rust.
fixing this might be beyond my current grasp of internals of Roc but as a genera question, does it make sense to write tests for functions kept in roc/examples/cli/cli-platform/src/lib.rs
I have been talking about https://github.com/roc-lang/basic-cli sorry for any confusion
Hi @Jakub,
I'll look into the DIr.list failure, in the meantime you could use the ls command as a workaround.
I was thinking about creating dev Docker image in case people would like to try out Roc without having to go through the installation process.
You can add a Dockerfile to the repo if you are also willing to set up a github workflow to test it, see this script for inspiration.
There is now an issue for setting up a docker image #6045
Last updated: Jul 06 2025 at 12:14 UTC