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

Give better error message when a global option is passed after command, not before (was "Option --config-file not recognized out of order") #7704

Open
andreasabel opened this issue Oct 6, 2021 · 5 comments
Labels
attention: pr-welcome cabal-install: cmd/sdist re: config-file Concerning the cabal configuration file and the `--config-file` option re: options Concerning command-line options type: discussion

Comments

@andreasabel
Copy link
Member

andreasabel commented Oct 6, 2021

--config-file is listed as global option by cabal --help, but get/unpack does not recognize it:

$ cabal get --config-file=foo
Error: cabal: unrecognized 'get' option `--config-file=foo'

(Spawned from #7702 (comment).)

UPDATE:

$ cabal --config-file=foo get bar

works, so this is merely an issue about a more user-friendly parsing of command-line options.

@andreasabel andreasabel added cabal-install: cmd/get re: options Concerning command-line options labels Oct 6, 2021
@andreasabel andreasabel changed the title cabal get does not recognize option --config-file Option --config-file not recognized out of order Oct 6, 2021
@andreasabel andreasabel added re: config-file Concerning the cabal configuration file and the `--config-file` option and removed cabal-install: cmd/get labels Oct 6, 2021
@Mikolaj
Copy link
Member

Mikolaj commented Oct 6, 2021

Ouch. I missed the order of options thing. Yes, we'd benefit from more relaxed parsing or a better error message, ideally recognizing the option and asking to reverse the order.

@gbaz
Copy link
Collaborator

gbaz commented Oct 6, 2021

All global options are required to go before commands, and --help documents this. Changing it seems rather difficult.

@Mikolaj
Copy link
Member

Mikolaj commented Oct 6, 2021

You are right, --help is explicit about this, in one of the first lines.

However, a better error message would help.

@Mikolaj Mikolaj changed the title Option --config-file not recognized out of order Give better error message when a global option is passed after command, not before (was "Option --config-file not recognized out of order") Oct 6, 2021
@Mikolaj
Copy link
Member

Mikolaj commented Oct 6, 2021

@andreasabel: I took the liberty of changing the title of the ticket. Please feel free to revert.

@jneira
Copy link
Member

jneira commented Feb 18, 2022

+1 to this, a small change which we imrprove beginners experience a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention: pr-welcome cabal-install: cmd/sdist re: config-file Concerning the cabal configuration file and the `--config-file` option re: options Concerning command-line options type: discussion
Projects
None yet
Development

No branches or pull requests

4 participants