Command line option parsers: Difference between revisions
(Say when download stats were gathered.) |
Andreas.abel (talk | contribs) (Added maintenance status column; console-program is unmaintained) |
||
Line 5: | Line 5: | ||
{| 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 !! Remark | ||
|- | |- | ||
| {{HackagePackage|id=argparser}} || - || None (though it depends on package containers, which uses extensions) || | | {{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=cmdargs}} || X || TemplateHaskell, SYB generics, ViewPatterns, ... || || <hask>unsafePerformIO</hask> | ||
|- | |- | ||
| {{HackagePackage|id=cmdlib}} || X || SYB generics || based on [[GetOpt]] | | {{HackagePackage|id=cmdlib}} || X || SYB generics || || based on [[GetOpt]] | ||
|- | |- | ||
| {{HackagePackage|id=cmdtheline}} || X || FlexibleInstances (although unnecessary) || shows help as man-page | | {{HackagePackage|id=cmdtheline}} || X || FlexibleInstances (although unnecessary) || || shows help as man-page | ||
|- | |- | ||
| {{HackagePackage|id=console-program}} || X || (none) || configure options via files | | {{HackagePackage|id=console-program}} || X || (none) || latest (0.4.2.3) only for GHC <= 8.8; no issue tracker (2021-10-23) || configure options via files | ||
|- | |- | ||
| {{HackagePackage|id=getflag}} || - || Haskell98 || like [[GetOpt]] but with Unix/Plan 9 option syntax | | {{HackagePackage|id=getflag}} || - || Haskell98 || || like [[GetOpt]] but with Unix/Plan 9 option syntax | ||
|- | |- | ||
| {{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=hflags}} || - || TemplateHaskell || || inspired by Google's gflags, provides parsed options in top-level variables, allow to set options via environment variables | ||
|- | |- | ||
| {{HackagePackage|id=multiarg}} || - || CPP || long options with multiple arguments | | {{HackagePackage|id=multiarg}} || - || CPP || || long options with multiple arguments | ||
|- | |- | ||
| {{HackagePackage|id=options}} || X || || | | {{HackagePackage|id=options}} || X || || | ||
|- | |- | ||
| {{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=optparse-applicative}} || X || GADT || active (2021-10-23) || 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=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=ReadArgs}} || - || OverlappingInstances, TypeOperators || || No options, only arguments. The argument template is derived from the requested argument tuple. | ||
|- | |- | ||
| {{HackagePackage|id=simpleargs}} || - || OverlappingInstances (although unnecessary) || the same as ReadArgs | | {{HackagePackage|id=simpleargs}} || - || OverlappingInstances (although unnecessary) || || the same as ReadArgs | ||
|- | |- | ||
| {{HackagePackage|id=uu-options}} || - || || Uses the less popular data-lens. Error correction. | | {{HackagePackage|id=uu-options}} || - || || || Uses the less popular data-lens. Error correction. | ||
|} | |} | ||
Revision as of 07:33, 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.
Package | Multi-mode | Extensions | Maintenance | Remark |
---|---|---|---|---|
argparser | - | None (though it depends on package containers, which uses extensions) | ||
cmdargs | X | TemplateHaskell, SYB generics, ViewPatterns, ... | unsafePerformIO
| |
cmdlib | X | SYB generics | based on GetOpt | |
cmdtheline | X | FlexibleInstances (although unnecessary) | shows help as man-page | |
console-program | X | (none) | latest (0.4.2.3) only for GHC <= 8.8; no issue tracker (2021-10-23) | configure options via files |
getflag | - | Haskell98 | like GetOpt but with Unix/Plan 9 option syntax | |
hflags | - | TemplateHaskell | inspired by Google's gflags, provides parsed options in top-level variables, allow to set options via environment variables | |
multiarg | - | CPP | long options with multiple arguments | |
options | X | |||
optparse-applicative | X | GADT | active (2021-10-23) | Applicative Functor; for wrong arguments it does not show a specific error message but the general usage pattern |
parseargs | - | FlexibleInstances (although unnecessary) | supports a fixed set of argument types: Int, Integer, Float, Double, String, FileOpener
| |
ReadArgs | - | OverlappingInstances, TypeOperators | No options, only arguments. The argument template is derived from the requested argument tuple. | |
simpleargs | - | OverlappingInstances (although unnecessary) | the same as ReadArgs | |
uu-options | - | 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.