folks, any way to run roc format
passing in a string directly? this can be used by code editors for auto-format for instance. :)
I actually want to have a libroc
or something - like a C library - for use cases like this
so it can be lower overhead than having to spawn the CLI, and also means the main Roc CLI can avoid having to mix tooling use cases in with normal Roc program author use cases :big_smile:
If you want something very hacky, a couple days ago, I quickly modified https://github.com/roc-lang/roc/blob/main/crates/cli/src/format.rs to make a Rust function that formats a string: https://gist.github.com/AjaiKN/a0778bf34d525686748a6568b7c298ba. I used cargo add --git https://github.com/roc-lang/roc roc_fmt
and cargo add --git https://github.com/roc-lang/roc roc_parse
to get the dependencies from the main branch on GitHub.
Last updated: Jul 06 2025 at 12:14 UTC