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

[ bsd3, cli, library, options, parsing, system ] [ Propose Tags ] [ Report a vulnerability ]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 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:14:58Z
Distributions LTSHaskell:1.0.0.0, Stackage:1.0.0.0
Downloads 752 total (13 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-07-21 [all 1 reports]

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!"