talira

optparse-generic

Auto-generate a Haskell command-line parser from your data type

open sourceBSD-3-Clausefree

optparse-generic generates a command-line interface from a Haskell data type with generic programming: derive Generic, add a ParseRecord instance and call getRecord, and record fields become flags with --help text. A type with several constructors becomes subcommands, and a Maybe field becomes an optional flag or argument. It builds on optparse-applicative and is by Gabriella Gonzalez.

Problems it solves

  • parse command-line arguments into a Haskell record without boilerplate
  • add subcommands to a Haskell CLI from a sum type
  • write a quick Haskell script with typed CLI flags

Features

  • CLI parser derived from a data type
  • generated --help text
  • subcommands from multiple constructors
  • optional flags from Maybe fields

Alternatives

The same job

These do what optparse-generic does.

  1. optparse-applicative Applicative command-line option parser for Haskell

Compare optparse-generic with the top 3