Difference between revisions of "Command line option parsers"

From HaskellWiki
Jump to navigation Jump to search
(add uu-options)
(Added popularity column (hackage downloads))
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
There are several packages that want to simplify the task of writing command line parsers. Unfortunately, they are distributed across several Hackage categories. Here is an attempt to list them:
+
There are several packages that want to simplify the task of writing command line parsers. Unfortunately, they are distributed across several Hackage categories. Here is an attempt to list them.
  +
  +
Based on Hackage downloads, as of May 2017, cmdargs (126k downloads) and optparse-applicative (120k downloads) are the most popular. (Still true as of Oct 2021.)
   
 
{| class="wikitable" border="1" style="border-collapse:collapse"
 
{| class="wikitable" border="1" style="border-collapse:collapse"
 
|-
 
|-
! Package !! Multi-mode !! Extensions !! Remark
+
! Package !! Multi-mode !! Extensions !! Maintenance !! Popularity (hackage downloads 2021-10-23) !! Remark
|-
 
| {{HackagePackage|id=argparser}} || - || None (though it depends on package containers, which uses extensions) ||
 
 
|-
 
|-
| {{HackagePackage|id=cmdargs}} || X || TemplateHaskell, SYB generics, ViewPatterns, ... || <hask>unsafePerformIO</hask>
+
| {{HackagePackage|id=argparser}} || - || None (though it depends on package containers, which uses extensions) || GHC 9.0 build successful (2021-10-23) || 4k ||
 
|-
 
|-
| {{HackagePackage|id=cmdlib}} || X || SYB generics || based on [[GetOpt]]
+
| {{HackagePackage|id=cmdargs}} || X || TemplateHaskell, SYB generics, ViewPatterns, ... || GHC 9.0 build successful (2021-10-23) || 225k || <hask>unsafePerformIO</hask>
 
|-
 
|-
| {{HackagePackage|id=cmdtheline}} || X || FlexibleInstances (although unnecessary) || shows help as man-page
+
| {{HackagePackage|id=cmdlib}} || X || SYB generics || DEAD: latest (0.3.6) only for GHC <= 8.4; no repo (2021-10-23) || 10k || based on [[GetOpt]]
 
|-
 
|-
| {{HackagePackage|id=console-program}} || X || (none) || configure options via files
+
| {{HackagePackage|id=cmdtheline}} || X || FlexibleInstances (although unnecessary) || DEAD: latest (0.2.3) only for GHC <= 7.8; no repo (2021-10-23) || 13k || shows help as man-page
 
|-
 
|-
| {{HackagePackage|id=getflag}} || - || Haskell98 || like [[GetOpt]] but with Unix/Plan 9 option syntax
+
| {{HackagePackage|id=console-program}} || X || (none) || DYING: latest (0.4.2.3) only for GHC <= 8.8; no issue tracker (2021-10-23) || 15k || configure options via files
 
|-
 
|-
| {{HackagePackage|id=hflags}} || - || TemplateHaskell || inspired by Google's gflags, provides parsed options in top-level variables, allow to set options via environment variables
+
| {{HackagePackage|id=getflag}} || - || Haskell98 || GHC 9.0 build successful (2021-10-23) || 1k || like [[GetOpt]] but with Unix/Plan 9 option syntax
 
|-
 
|-
| {{HackagePackage|id=multiarg}} || - || CPP || long options with multiple arguments
+
| {{HackagePackage|id=hflags}} || - || TemplateHaskell || GHC 9.0 build successful (2021-10-23) || 10k || inspired by Google's gflags, provides parsed options in top-level variables, allow to set options via environment variables
 
|-
 
|-
| {{HackagePackage|id=options}} || X || TemplateHaskell ||
+
| {{HackagePackage|id=multiarg}} || - || CPP || GHC 9.0 build successful (2021-10-23) || 17k || long options with multiple arguments
 
|-
 
|-
| {{HackagePackage|id=optparse-applicative}} || X || GADT || Applicative Functor; for wrong arguments it does not show a specific error message but the general usage pattern
+
| {{HackagePackage|id=options}} || X || || GHC 9.0 build successful (2021-10-23) || 11k ||
 
|-
 
|-
  +
| {{HackagePackage|id=optparse-applicative}} || X || GADT || GHC 9.0 build successful (2021-10-23) || 254k || Applicative Functor; for wrong arguments it does not show a specific error message but the general usage pattern
| {{HackagePackage|id=parseargs}} || - || FlexibleInstances (although unnecessary) || supports a fixed set of argument types: <hask>Int, Integer, Float, Double, String, FileOpener</hask>
 
 
|-
 
|-
| {{HackagePackage|id=ReadArgs}} || - || OverlappingInstances, TypeOperators || No options, only arguments. The argument template is derived from the requested argument tuple.
+
| {{HackagePackage|id=parseargs}} || - || FlexibleInstances (although unnecessary) || GHC 9.0 build successful (2021-10-23) || 18k || supports a fixed set of argument types: <hask>Int, Integer, Float, Double, String, FileOpener</hask>
 
|-
 
|-
| {{HackagePackage|id=simpleargs}} || - || OverlappingInstances (although unnecessary) || the same as ReadArgs
+
| {{HackagePackage|id=ReadArgs}} || - || OverlappingInstances, TypeOperators || GHC 9.0 build successful (2021-10-23) || 20k || No options, only arguments. The argument template is derived from the requested argument tuple.
 
|-
 
|-
| {{HackagePackage|id=uu-options}} || - || || Uses the less popular data-lens. Error correction.
+
| {{HackagePackage|id=simpleargs}} || - || OverlappingInstances (although unnecessary) || DEAD: latest (0.2.1) only for GHC <= 8.0; no repo (2021-10-23) || 2k || the same as ReadArgs
 
|-
 
|-
| {{HackagePackage|id=yaop}} || - || TemplateHaskell, GeneralizedNewtypeDeriving || wrapper around GetOpt
+
| {{HackagePackage|id=uu-options}} || - || || latest (0.2.0.0) only for GHC <= 8.10 (2021-10-23) || 3k || Uses the less popular data-lens. Error correction.
 
|}
 
|}
   

Latest revision as of 09:41, 23 October 2021

There are several packages that want to simplify the task of writing command line parsers. Unfortunately, they are distributed across several Hackage categories. Here is an attempt to list them.

Based on Hackage downloads, as of May 2017, cmdargs (126k downloads) and optparse-applicative (120k downloads) are the most popular. (Still true as of Oct 2021.)

Package Multi-mode Extensions Maintenance Popularity (hackage downloads 2021-10-23) Remark
argparser - None (though it depends on package containers, which uses extensions) GHC 9.0 build successful (2021-10-23) 4k
cmdargs X TemplateHaskell, SYB generics, ViewPatterns, ... GHC 9.0 build successful (2021-10-23) 225k unsafePerformIO
cmdlib X SYB generics DEAD: latest (0.3.6) only for GHC <= 8.4; no repo (2021-10-23) 10k based on GetOpt
cmdtheline X FlexibleInstances (although unnecessary) DEAD: latest (0.2.3) only for GHC <= 7.8; no repo (2021-10-23) 13k shows help as man-page
console-program X (none) DYING: latest (0.4.2.3) only for GHC <= 8.8; no issue tracker (2021-10-23) 15k configure options via files
getflag - Haskell98 GHC 9.0 build successful (2021-10-23) 1k like GetOpt but with Unix/Plan 9 option syntax
hflags - TemplateHaskell GHC 9.0 build successful (2021-10-23) 10k inspired by Google's gflags, provides parsed options in top-level variables, allow to set options via environment variables
multiarg - CPP GHC 9.0 build successful (2021-10-23) 17k long options with multiple arguments
options X GHC 9.0 build successful (2021-10-23) 11k
optparse-applicative X GADT GHC 9.0 build successful (2021-10-23) 254k Applicative Functor; for wrong arguments it does not show a specific error message but the general usage pattern
parseargs - FlexibleInstances (although unnecessary) GHC 9.0 build successful (2021-10-23) 18k supports a fixed set of argument types: Int, Integer, Float, Double, String, FileOpener
ReadArgs - OverlappingInstances, TypeOperators GHC 9.0 build successful (2021-10-23) 20k No options, only arguments. The argument template is derived from the requested argument tuple.
simpleargs - OverlappingInstances (although unnecessary) DEAD: latest (0.2.1) only for GHC <= 8.0; no repo (2021-10-23) 2k the same as ReadArgs
uu-options - latest (0.2.0.0) only for GHC <= 8.10 (2021-10-23) 3k Uses the less popular data-lens. Error correction.

The column for required Haskell extensions gives an idea of how easy it is to port the package to compilers other than GHC.