Skip to content
This repository

Allow omitting the double dash when running `cabal run` #1119

Open
23Skidoo opened this Issue · 5 comments

3 participants

Mikhail Glushenkov Dag Odenhall Johan Tibell
Mikhail Glushenkov
Owner

As discussed in #1088, cabal run currently requires separating the executable's options from run flags with --:

$ cabal run foo -- -bar baz 
./dist/build/foo/foo -bar baz
$ cabal run foo -bar baz
Unrecognized option: -bar

It would be nice to make the -- optional while still allowing passing options (e.g. --env-var) to run itself. One way to implement this is to treat all input after and including the first unrecognised option as executable's options. However, making this work seems to require modifying both Distribution.Simple.Command and Distribution.GetOpt.

Mikhail Glushenkov
Owner

Assigning this to myself so that I don't forget about the issue.

Dag Odenhall

Why not require that flags to run come before the executable name, and then any arguments after it are treated as executable flags? You'd still need -- to run the "default" executable without naming it but I think that's sensible.

Dag Odenhall

I think this is already a distinction cabal-install does with global vs command-specific flags, e.g. cabal --numeric-version install works but not cabal install --numeric-version. With my suggestion, the executable name becomes a sub-command of the run command, of sorts.

Mikhail Glushenkov
Owner

This requires reworking the way we parse options. E.g. there is no direct support for subcommands (#1257), which is why all cabal sandbox subcommands accept --snapshot, instead of only add-source.

Johan Tibell
Owner

What @23Skidoo said. It's a limitation in how getopt works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.