optparse-applicative-dex: Extra functions for working with optparse-applicative

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

optparse-applicative is a fantastic library

My usage of it has often used the same features wrapped in a parseOpts function along with a version helper.

This package abstracts that code into a re-usable library, minimizing pasting between projects.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0, 1.0.1
Change log CHANGELOG.md
Dependencies base (>=3 && <5), optparse-applicative (>=0.17.1 && <0.19), prettyprinter (>=1.7.1 && <2), text (>=1.11.1 && <3) [details]
License ISC
Copyright 2025 Dino Morelli
Author Dino Morelli
Maintainer dino@ui3.info
Category CLI, Console, Options, Parsing
Source repo head: git clone https://codeberg.org/dinofp/optparse-applicative-dex
Uploaded by DinoMorelli at 2025-09-05T14:28:26Z
Distributions
Downloads 4 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-09-05 [all 1 reports]

Readme for optparse-applicative-dex-1.0.0

[back to package description]

optparse-applicative-dex

Synopsis

Extra functions for working with optparse-applicative

Description

optparse-applicative is a fantastic library

My usage of it has often used the same features wrapped in a parseOpts function along with a version helper.

This package abstracts that code into a re-usable library, minimizing pasting between projects.

In most CLI projects I almost always want:

  • A header consisting of the program name and a short description
  • A helper parser to provide -h, --help
  • A version helper to respond to a --version option with shorter output than -h, --help
  • Some additional usage info below the generated switch usage

The parseOpts' and parseOptsWithWidth functions in this library take a parser and arguments for header, footer and the app version as generated by cabal and do all these things automatically.

A simple example:

{- # LANGUAGE OverloadedStrings #-}

import Options.Applicative.Dex
import Paths_your_app (version)

data Options = Options { optA :: String , optB :: Bool }
  deriving Show

parser :: Parser Options
parser = Options
  <$> option str ( short 'a' <> metavar "STR" <> help "The a option, a string" )
  <*> switch ( short 'b' <> help "The b option, a switch")

main :: IO ()
main = do
  opts <- parseOpts' parser "header-info" "footer-info" version
  print opts

Getting source

Source code is available from codeberg at the optparse-applicative-dex project page.

Contact

Dino Morelli dino@ui3.info