Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow omitting the double dash when running cabal run #1119

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

Allow omitting the double dash when running cabal run #1119

23Skidoo opened this issue Nov 16, 2012 · 6 comments

Comments

@23Skidoo
Copy link
Member

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
Copy link
Member Author

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

@dag
Copy link

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
Copy link

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
Copy link
Member Author

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
Copy link
Member

tibbe commented Dec 4, 2013

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

@BardurArantsson
Copy link
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.

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

No branches or pull requests

8 participants