just came up with a nice ergonomics improvement for the Roc CLI:
https://github.com/rtfeldman/roc/issues/3222
Any reason for "root" and not "main" or similar? Just trying to think if there are other more common naming conventions that might be more proper to use.
Side, note, would it be possible to just grab this information from the Package-Config.roc and instead start there?
ooh I like main!
the terminology I've been using in my head for the [app/platform/package] module is "the root module of your project" because it imports all the other modules, so it's at the root of the dependency tree
but main.roc seems like a much better fit for app modules, and seems fine for packages and platforms too :thumbs_up:
isn't this what -- is for. So I can cargo run -- arg for the app vs cargo run args for cargo
no need to add an extra flag for that
also packages don't have a root right?
packages need a root package module just like apps have an app module and platforms have a platform module - to specify things like "here are the packages I depend on, here are the modules that I want to publicly expose" etc
I thought about -- but it seems like that would make the typical case less convenient in order to make the rare case more convenient, whereas --root (or --main) would make the typical case more convenient and the rare case less convenient
-- is pretty standard though?
sure, which is why I'd go for it if it were the most convenient, but I think we can do better than the standard! :smiley:
well going "against the standard" is in itself confusing. And in designing the language you want to "spend the weirdness budget" somewhere to bring something new to the table. But when it comes to how cli arguments are parsed I think the tradeoff is different
also how would you pass flags to the compiler, like what target or linker to use? it's order-dependent ?
E.g. here how do I distinguish arguments for the application vs for the compiler?
roc run --main=Foo.roc --linker=legacy arg1 arg2
oh I see
versus
roc run Foo.roc --linker=legacy -- arg1 arg2
like if you want to pass an argument to the application that happens to have the same name as an argument the compiler CLI accepts
including a flag
interesting
this is exactly what -- solves: it kind of does "scoping" of the arguments
so cargo run makes -- optional - should we make it required, just to be explicit about that?
right, cargo run --help is ambiguous, for instance
we should pick whatever can give the best error messages here when it fails. I'm not sure which that is
making it required is probably a good default that you can later relax
makes sense! I updated the issue
:thinking: maybe we should do both?
I could see it being confusing if I did roc run datafile.json and got an error about how datafile.json is not valid Roc source code
On top of what @Folkert de Vries already mentioned: What if you build a Roc program that itself wants to use the --main (or insert whatever flag roc also supports) flag?
Usage of -- is a clear way to scope the arguments. The other alternative that I've seen in some places is to wrap all (or any potentially conflicting) arguments in an extra layer of nesting, say --app-arg="--main" which becomes very tedious very quickly (for instance needing to doubly escape strings)
yeah I'm sold on --
Last updated: Jun 16 2026 at 16:19 UTC