Package Info

ghc-options


A powerful and easy-to-use command-line option parser


Development/Libraries/Haskell

The 'options' package lets library and application developers easily work with command-line options.

The following example is a full program that can accept two options, '--message' and '--quiet':

' import Control.Applicative import Options

data MainOptions = MainOptions   { optMessage :: String   , optQuiet :: Bool   }

instance 'Options' MainOptions where &#x20; defineOptions = pure MainOptions &#x20; <> simpleOption "message" "Hello world!" &#x20; "A message to show the user." &#x20; <> simpleOption "quiet" False &#x20; "Whether to be quiet."

main :: IO () main = runCommand $ \opts args -> do &#x20; if optQuiet opts &#x20; then return () &#x20; else putStrLn (optMessage opts) '

>$ ./hello >Hello world! >$ ./hello --message='ciao mondo' >ciao mondo >$ ./hello --quiet >$

In addition, this library will automatically create documentation options such as '--help' and '--help-all':

>$ ./hello --help >Help Options: > -h, --help > Show option summary. > --help-all > Show all help options. > >Application Options: > --message :: text > A message to show the user. > default: "Hello world!" > --quiet :: bool > Whether to be quiet. > default: false.


License: MIT
URL: https://hackage.haskell.org/package/options

Categories

Releases

Package Version Update ID Released Package Hub Version Platforms Subpackages
1.2.1.1-bp150.2.5 info GA Release 2018-08-01 15
  • AArch64
  • ghc-options
  • ghc-options-devel
1.2.1.1-bp150.2.7 info GA Release 2018-07-30 15
  • ppc64le
  • x86-64
  • ghc-options
  • ghc-options-devel