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

Open
23Skidoo opened this Issue Nov 16, 2012 · 6 comments

Comments

Projects
None yet
6 participants
@23Skidoo
Member

23Skidoo commented Nov 16, 2012

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.

@23Skidoo

This comment has been minimized.

Show comment Hide comment
@23Skidoo

23Skidoo Nov 17, 2012

Member

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

Member

23Skidoo commented Nov 17, 2012

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

@dag

This comment has been minimized.

Show comment Hide comment
@dag

dag Dec 4, 2013

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 commented Dec 4, 2013

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

This comment has been minimized.

Show comment Hide comment
@dag

dag Dec 4, 2013

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.

dag commented Dec 4, 2013

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.

@23Skidoo

This comment has been minimized.

Show comment Hide comment
@23Skidoo

23Skidoo Dec 4, 2013

Member

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.

Member

23Skidoo commented Dec 4, 2013

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.

@tibbe

This comment has been minimized.

Show comment Hide comment
@tibbe

tibbe Dec 4, 2013

Owner

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

Owner

tibbe commented Dec 4, 2013

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

@BardurArantsson

This comment has been minimized.

Show comment Hide comment
@BardurArantsson

BardurArantsson Sep 5, 2015

Collaborator

I have a simple question: Why?

IMO "it would be nice" is extremely weak justification and there's no actual use case presented.

Given the complexity/invasiveness of implementation I think this should just be closed.

Also, requiring "--" is pretty standard for pretty much everything which takes "a subprogram to run" as an argument.

Collaborator

BardurArantsson commented Sep 5, 2015

I have a simple question: Why?

IMO "it would be nice" is extremely weak justification and there's no actual use case presented.

Given the complexity/invasiveness of implementation I think this should just be closed.

Also, requiring "--" is pretty standard for pretty much everything which takes "a subprogram to run" as an argument.

@23Skidoo 23Skidoo modified the milestones: cabal-install 1.24, cabal-install 1.26 Feb 21, 2016

@ezyang ezyang modified the milestone: cabal-install 2.0 Sep 6, 2016

@23Skidoo 23Skidoo removed their assignment Sep 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment