ndmitchell / cmdargs

Haskell library for command line argument processing
Other
91 stars 12 forks source link

Better error messages for invalid annotations #30

Open ndmitchell opened 9 years ago

ndmitchell commented 9 years ago

From http://code.google.com/p/ndmitchell/issues/detail?id=345

in_files   = [] &= help "CVS files with data to visualise"
                &= args
                &= typ "FILES"

This is invalid because args and help don't mix, but you get the error:

System.Console.CmdArgs.Implicit, unexpected flag (args/argPos):
     Flag_ {flagField = "in_files",
            flagFlag  = CVS files with data to visualise,
            flagExplicit = False,
            flagGroup = Nothing,
            flagEnum = Nothing}

That's horrible, and misses the essential parts.

As another example, if you make the help field an unknown type, for example Text, you get the error message:

System.Console.CmdArgs.Implicit, unexpected flag (help): Data.Text.Internal.Text

It doesn't say that its an unexpected type, or that the flag is expected but the type is not.