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

UX: confusing error "invalid option" when options in wrong order #445

Closed
andreasabel opened this issue Dec 22, 2020 · 6 comments
Closed

Comments

@andreasabel
Copy link
Contributor

The error message Invalid option is confusing if the option is valid but in unexpected order.

Try 1:

$ haskell-ci github --jobs-selection any cabal.project
Invalid option `--jobs-selection'

Usage: haskell-ci github CABAL.FILE
  Generate GitHub Actions config

Try 2:

$ haskell-ci github --jobs-selection=any cabal.project
Invalid option `--jobs-selection=any'

Usage: haskell-ci github CABAL.FILE
  Generate GitHub Actions config

These work:

$ haskell-ci --jobs-selection=any github cabal.project
$ haskell-ci --jobs-selection any github cabal.project

$ haskell-ci github cabal.project --jobs-selection=any 
$ haskell-ci github cabal.project --jobs-selection any 

The command line syntax is declared as

Usage: haskell-ci (COMMAND | CABAL.FILE) [(-o|--output FILE) | --stdout] 
                  [--config CONFIGFILE] [--cwd Dir] [----package | ----project] 
                  [--cabal-install-version VERSION | --jobs JOBS | 
                    --distribution DIST | --jobs-selection uniform|any | 
...                   
                    --raw-travis ARG] [-V|--version]

but this syntax is apparently not followed by the command line parser; at least if the bar is to be read as usual as "alternative".
Maybe switch to https://github.com/pcapriotti/optparse-applicative ? This framework automatically generates a correct description of the command line syntax.

@phadej
Copy link
Collaborator

phadej commented Dec 22, 2020

Maybe switch to https://github.com/pcapriotti/optparse-applicative ?

We are using optparse-applicative.

@phadej phadej closed this as completed Dec 22, 2020
@phadej
Copy link
Collaborator

phadej commented Dec 22, 2020

I think this will be fixed by #446, if it's not, then I don't know how to fix it.

@andreasabel
Copy link
Contributor Author

Isn't fixed, at least not by commit 93fa5dc

Author: Oleg Grenrus 
Date:   Tue Dec 22 12:28:38 2020 +0200

    Use subparserInline

@phadej
Copy link
Collaborator

phadej commented Dec 22, 2020

haskell-ci master % git log -2                                                       
commit a6523e6ecf6e1e9d5eb255be87004422aba84c05 (HEAD -> master, origin/master, origin/HEAD)
Author: Oleg Grenrus <[email protected]>
Date:   Tue Dec 22 13:50:14 2020 +0200

    Add -Wincomplete-uni-patterns

commit 43dac87aba4cadd2f1e1d688285df171c341f472
Merge: f844879 93fa5dc
Author: Oleg Grenrus <[email protected]>
Date:   Tue Dec 22 12:37:19 2020 +0200

    Merge pull request #446 from haskell-CI/issue-445
    
    Use subparserInline
haskell-ci master % cabal run -- haskell-ci github --jobs-selection any cabal.project
Up to date
*INFO* Generating GitHub config for testing for GHC versions: 8.2.2 8.4.4 8.6.5 8.8.4 8.10.3
*INFO* haskell-ci : 8.2.2 8.4.4 8.6.5 8.8.4 8.10.3
*INFO* cabal-install-parsers : 8.2.2 8.4.4 8.6.5 8.8.4 8.10.3
haskell-ci master % cabal run -- haskell-ci github --jobs-selection uniform cabal.project
Up to date
*INFO* Generating GitHub config for testing for GHC versions: 8.2.2 8.4.4 8.6.5 8.8.4 8.10.3

@phadej
Copy link
Collaborator

phadej commented Dec 22, 2020

I bumped the package version. cabal install sometimes does weird things, and reuses old internal library https://github.com/haskell/cabal/issues?q=is%3Aissue+is%3Aopen+internal+author%3Aphadej

I'm not sure if you hit it. (It's very hard to note).

@andreasabel
Copy link
Contributor Author

I bumped the package version. cabal install sometimes does weird things, and reuses old internal library https://github.com/haskell/cabal/issues?q=is%3Aissue+is%3Aopen+internal+author%3Aphadej

Likely, you meant haskell/cabal#6211.

I'm not sure if you hit it. (It's very hard to note).

This could have been the problem. It works now:

$ haskell-ci --version
0.11.20210101

$ haskell-ci github --jobs-selection any cabal.project
*INFO* Generating GitHub config for testing for GHC versions: 7.10.3 8.0.2 8.2.2 8.4.4 8.6.5 8.8.4 8.10.3
*INFO* BNFC : 7.10.3 8.0.2 8.2.2 8.4.4 8.6.5 8.8.4 8.10.3
*INFO* bnfc-system-tests : 8.2.2 8.4.4 8.6.5 8.8.4 8.10.3

Thanks!

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

No branches or pull requests

2 participants