Skip to content

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

Closed
@andreasabel

Description

@andreasabel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions