hsoptions
Haskell library that supports command-line flag processing
Haskell library that supports command-line flag processing.
Too see an user guide and list of features go to
<https://github.com/josercruz01/hsoptions#table-of-contents>.
Flags are declared in the code by using the 'make' function, which takes the
flag's name, help text and type as arguments.
The flags are parsed from the command line stream of from a file
if the @--usingFile \<filename\>@ flag is sent to the program.
Flags can be customized by calling configuration function, such as
'defaultIs' or 'aliasIs', that change how the flag behaves, how it
is parsed and validated.
The 'processMain' function needs to be called at the beginning of the 'main'
function. This function takes as arguments:
* The @program description@
* A list of @all declared flags@
* Three callbacks:
* * @success@
* * @failure@
* * @display help@
If there is any kind of validation error @failure@ is
called with the list of errors. If the @--help@ flag was sent by the user
@display help@ is called. Otherwise if there are no problems the @success@
function is called.
A default implementation of @failure@ and @display help@ is provided in the
library ('defaultDisplayHelp', 'defaultDisplayErrors') with a basic bahavior.
Basically @success@ becomes the \'real\' main function. It takes as argument
a tuple ('FlagResults', 'ArgsResults'). 'FlagResults' is a data structure
that can be used to query flags by using the 'get' function. 'ArgsResults' is
just an array of 'String' containing the remaining not-flag arguments.
A simple example (more in
<https://github.com/josercruz01/hsoptions/tree/master/examples>)
> import System.Console.HsOptions
>
> userName = make ( "user_name",
> , "the user name of the app",
> , [ parser stringParser,
> , aliasIs ["u"]
> ]
> )
> userAge = make ("age", "the age of the user", [parser intParser])
>
> flagData = combine [flagToData userName, flagToData userAge]
>
> main :: IO ()
> main = processMain "Simple example for HsOptions."
> flagData
> success
> failure
> defaultDisplayHelp
>
> success :: ProcessResults -> IO ()
> success (flags, args) = do let nextAge = (flags `get` userAge) + 5
> putStrLn ("Hello " ++ flags `get` userName)
> putStrLn ("In 5 years you will be " ++
> show nextAge ++
> " years old!")
>
> failure :: [FlagError] -> IO ()
> failure errs = do putStrLn "Some errors occurred:"
> mapM_ print errs
At the 'processMain' function each of the input flags is validated against the
declared flags. Within the @success@ function you can be sure that all required
flags exist, all flag types are correct and all validation was successful.
| version | uploaded | uploader | changes | |
|---|---|---|---|---|
| 1.0.0.0 | 2014-04-28 18:41 UTC | josercruz01 | +4191/−0 lines, 15 filesdep +HUnitdep +QuickCheckdep +basesetup-changed |
Dependencies of hsoptions-1.0.0.0
HUnit >=1.2 && <2 1.6.1.0 → 1.6.2.0
| 2021-01-19 18:27 UTC | 1.6.2.0 | +48/−42 lines, 5 filesdep ~call-stackPVP: major bump suggested |
| 2020-10-31 12:09 UTC | 1.6.1.0 | +35/−21 lines, 4 filesPVP ok |
| 2017-03-20 01:42 UTC | 1.6.0.0 | +9/−5 lines, 4 filesdep ~basePVP ok |
| 2016-10-16 03:35 UTC | 1.5.0.0 | +47/−27 lines, 5 filesPVP ok |
| 2016-10-07 03:13 UTC | 1.4.0.0 | +761/−778 lines, 12 filesdep +call-stackPVP ok |
showing 5 of 22 versions
QuickCheck >=2.4 && <=2.7 2.7 → 2.19.0.0 newer than bounds
| 2026-09-16 11:18 UTC | 2.19.0.0 newer than bounds | +67/−41 lines, 10 filesdep +OneTuplePVP ok |
| 2026-02-26 12:42 UTC | 2.18.0.0 newer than bounds | +826/−542 lines, 23 filesPVP ok |
| 2025-10-13 12:40 UTC | 2.17.1.0 newer than bounds | +18/−8 lines, 4 filesdep ~randomPVP: major bump suggested |
| 2025-10-07 12:26 UTC | 2.17.0.0 newer than bounds | +667/−129 lines, 14 filesdep +data-array-bytedep +hintdep +splitdep −ghc-primdep −old-localedep −old-timedep ~basedep ~randomdep ~template-haskellPVP ok |
| 2025-06-17 07:53 UTC | 2.16.0.0 newer than bounds | +477/−86 lines, 15 filesdep ~basenew-uploaderPVP ok |
showing 5 of 66 versions
base >=4.6 && <4.7 4.6.0.1 → 4.22.1.0 newer than bounds
| 2026-12-01 12:38 UTC | 4.22.1.0 newer than bounds | +388/−6 lines, 9 filesdep ~ghc-internalPVP: major bump suggested |
| 2025-12-19 11:52 UTC | 4.22.0.0 newer than bounds | +886/−215 lines, 28 filesdep ~ghc-internalPVP ok |
| 2026-03-27 12:26 UTC | 4.21.2.0 newer than bounds | +10/−3 lines, 4 filesdep ~ghc-internalPVP ok |
| 2025-12-27 10:31 UTC | 4.21.1.0 newer than bounds | +17/−5 lines, 4 filesdep ~ghc-internalPVP ok |
| 2024-12-16 09:24 UTC | 4.21.0.0 newer than bounds | +1170/−396 lines, 39 filesdep ~ghc-internalPVP ok |
showing 5 of 61 versions
containers >=0.5 && <0.6 0.5.11.0 → 0.8.1 newer than bounds
| 2026-10-04 06:08 UTC | 0.8.1 newer than bounds | +8085/−5169 lines, 39 filesdep +template-haskell-liftdep ~arraydep ~deepseqPVP: major bump suggested |
| 2025-03-01 13:03 UTC | 0.8 newer than bounds | +8447/−7031 lines, 37 filesnew-uploaderPVP ok |
| 2023-09-27 12:15 UTC | 0.7 newer than bounds | +76/−33 lines, 3 filesPVP ok |
| 2023-09-28 04:21 UTC | 0.6.8 newer than bounds | +644/−184 lines, 17 filesdep ~basedep ~deepseqPVP: major bump suggested |
| 2023-02-01 03:11 UTC | 0.6.7 newer than bounds | +783/−229 lines, 20 filesPVP: major bump suggested |
showing 5 of 43 versions
directory >=1.2 && <1.3 1.2.7.1 → 1.3.11.0 newer than bounds
| 2026-05-27 05:59 UTC | 1.3.11.0 newer than bounds | +4560/−4504 lines, 25 filesdep ~file-iodep ~filepathdep ~os-stringPVP ok |
| 2026-01-05 11:08 UTC | 1.3.10.1 newer than bounds | +4989/−4830 lines, 43 filesPVP: major bump suggested |
| 2025-12-24 02:55 UTC | 1.3.10.0 newer than bounds | +90/−39 lines, 7 filesdep ~Win32dep ~basePVP: major bump suggested |
| 2024-10-11 10:43 UTC | 1.3.9.0 newer than bounds | +235/−158 lines, 14 filesdep +file-iodep ~basedep ~timePVP: major bump suggested |
| 2024-05-20 06:52 UTC | 1.3.8.5 newer than bounds | +15/−13 lines, 7 filesdep ~basePVP ok |
showing 5 of 55 versions
parsec >=3.1 && <3.2 3.1.17.0 → 3.1.18.0
| 2025-01-05 00:08 UTC | 3.1.18.0 | +159/−170 lines, 7 filesdep −faildep ~basedep ~bytestringdep ~mtlPVP: major bump suggested |
| 2023-10-04 06:08 UTC | 3.1.17.0 | +112/−25 lines, 8 filesdep +deepseqdep ~basedep ~bytestringdep ~tastyPVP: major bump suggested |
| 2023-01-08 20:47 UTC | 3.1.16.1 | +6/−2 lines, 3 filesPVP ok |
| 2023-01-08 18:03 UTC | 3.1.16.0 | +124/−19 lines, 8 filesdep ~basePVP ok |
| 2022-05-10 10:14 UTC | 3.1.15.1 | +19/−15 lines, 9 filesdep ~basedep ~mtldep ~textPVP ok |
showing 5 of 27 versions
regex-compat >=0.95 && <0.96 0.95.2.1 → 0.95.2.2
| 2025-03-02 15:03 UTC | 0.95.2.2 | +70/−39 lines, 5 filesdep ~arraydep ~basesetup-changedPVP: major bump suggested |
| 2021-02-20 19:16 UTC | 0.95.2.1 | +61/−27 lines, 3 filesdep ~basenew-uploaderPVP ok |
| 2019-09-30 22:58 UTC | 0.95.2.0 | +63/−54 lines, 3 filesdep ~arraydep ~basedep ~regex-basenew-uploaderPVP: major bump suggested |
| 2011-05-09 18:01 UTC | 0.95.1 | +4/−4 lines, 1 filesdep ~regex-posixPVP ok |
| 2010-06-11 22:59 UTC | 0.93.1 outside bounds | +13/−26 lines, 2 filesdep ~basesetup-changedPVP ok |
showing 5 of 10 versions
regex-posix >=0.95 && <0.96 0.95.2 → 0.96.0.2 newer than bounds
| 2025-03-02 11:16 UTC | 0.96.0.2 newer than bounds | +125/−68 lines, 11 filesdep −faildep ~arraydep ~basedep ~bytestringsetup-changedPVP: major bump suggested |
| 2021-07-19 12:27 UTC | 0.96.0.1 newer than bounds | +117/−77 lines, 8 filesdep ~basedep ~bytestringdep ~containersnew-uploaderPVP: major bump suggested |
| 2019-09-30 22:16 UTC | 0.96.0.0 newer than bounds | +1354/−5736 lines, 29 filesdep +faildep +regex-posix-clibdep ~arraydep ~basedep ~bytestringnew-uploaderPVP ok |
| 2012-05-20 16:35 UTC | 0.95.2 | +16/−5 lines, 2 filesdep ~arraydep ~basedep ~bytestringPVP ok |
| 2011-05-09 15:55 UTC | 0.95.1 | +29/−3 lines, 4 filesPVP ok |
showing 5 of 20 versions
test-framework >=0.8 && <0.9 0.8.2.2 → 0.8.2.3
| 2026-01-05 13:44 UTC | 0.8.2.3 | +15/−15 lines, 3 filesdep −bytestringdep −old-localedep −semigroupsdep ~ansi-terminaldep ~ansi-wl-pprintdep ~hostnamePVP: major bump suggested |
| 2025-04-11 08:21 UTC | 0.8.2.2 | +34/−35 lines, 3 filesdep −libxmldep −utf8-stringdep ~QuickCheckPVP ok |
| 2025-02-26 19:51 UTC | 0.8.2.1 | +1700/−1542 lines, 55 filesdep +utf8-stringdep −base-orphansdep ~HUnitdep ~QuickCheckdep ~ansi-terminalsetup-changednew-uploaderPVP: major bump suggested |
| 2017-12-30 17:50 UTC | 0.8.2.0 | +134/−79 lines, 13 filesdep +base-orphansdep +semigroupsdep ~QuickCheckdep ~ansi-terminaldep ~ansi-wl-pprintsetup-changedPVP: major bump suggested |
| 2015-01-09 04:04 UTC | 0.8.1.1 | +7/−2 lines, 2 filesdep ~ansi-terminaldep ~timePVP ok |
showing 5 of 34 versions
test-framework-hunit >=0.3 && <0.4 0.3.0.2 → 0.3.0.3
| 2026-01-05 13:43 UTC | 0.3.0.3 | +42/−40 lines, 4 filesdep −extensible-exceptionsdep ~HUnitdep ~basedep ~test-frameworksetup-changednew-uploaderPVP ok |
| 2015-09-04 15:42 UTC | 0.3.0.2 | +12/−4 lines, 2 filesdep ~HUnitnew-uploader |
| 2013-10-09 00:28 UTC | 0.3.0.1 | +10/−4 lines, 1 filesnew-uploader |
| 2012-12-04 19:56 UTC | 0.3.0 | +4/−1 lines, 2 filesdep ~test-frameworkPVP ok |
| 2012-01-27 12:54 UTC | 0.2.7 outside bounds | +5/−5 lines, 2 filesPVP ok |
showing 5 of 12 versions
test-framework-quickcheck2 >=0.3 && <0.4 0.3.0.6 → 0.3.0.7
| 2026-01-05 13:43 UTC | 0.3.0.7 | +14/−10 lines, 3 filesdep −extensible-exceptionsPVP ok |
| 2025-02-26 19:51 UTC | 0.3.0.6 | +40/−33 lines, 4 filesdep ~QuickCheckdep ~basedep ~randomsetup-changednew-uploaderPVP ok |
| 2018-09-03 17:10 UTC | 0.3.0.5 | +12/−7 lines, 3 filesdep ~QuickCheckdep ~randomPVP ok |
| 2017-06-16 14:41 UTC | 0.3.0.4 | +47/−36 lines, 5 filesdep ~QuickCheckdep ~basedep ~test-frameworksetup-changednew-uploaderPVP: major bump suggested |
| 2014-04-11 10:30 UTC | 0.3.0.3 | +25/−4 lines, 2 filesdep ~QuickCheckdep ~randomdep ~test-frameworknew-uploader |
showing 5 of 24 versions
Reverse dependencies
no known reverse dependencies