optparse-enum: An enum-text based toolkit for optparse-applicative

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Please see the README on GitHub at https://github.com/cdornan/optparse-enum#readme


[Skip to Readme]

Properties

Versions 1.0.0.0, 1.0.0.0
Change log ChangeLog.md
Dependencies base (>=4.8 && <10), enum-text (>=0.5.1.0), fmt (>=0.6), optparse-applicative (>=0.12), text (>=1.2.2.2) [details]
License BSD-3-Clause
Copyright 2019 Chris Dornan
Author Chris Dornan
Maintainer chris@chrisdornan.com
Category System, CLI, Options, Parsing
Home page https://github.com/cdornan/optparse-enum#readme
Bug tracker https://github.com/cdornan/optparse-enum/issues
Source repo head: git clone https://github.com/cdornan/optparse-enum
Uploaded by ChrisDornan at 2019-07-21T17:13:51Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for optparse-enum-1.0.0.0

[back to package description]

optparse-enum

An enum-text based toolkit for optparse-applicative.

A simple but complete example:

{-# LANGUAGE DeriveAnyClass    #-}
{-# LANGUAGE DerivingVia       #-}
{-# LANGUAGE OverloadedStrings #-}

import Fmt
import Text.Enum.Optparse
import Paths_optparse_enum

data Choice
  = C_version
  | C_hello
  deriving (Bounded,Enum,EnumText,Eq,Ord,Show)
  deriving (Buildable,TextParsable) via UsingEnumText Choice

parserDetails ::   ParserDetails
parserDetails =
  ParserDetails
    { _pd_desc   = "optparse-enum example program"
    , _pd_header = "A simple optparse-enum illustrative program"
    , _pd_footer = "See the optparse-enum page on Hackage for details"
    }

main :: IO ()
main = do
  choice <- parseIO parserDetails enumSwitchesP
  case choice of
    C_version -> print    version
    C_hello   -> putStrLn "Hello!"