packages feed

optparse-applicative-dex 1.0.1 → 1.0.2

raw patch · 6 files changed

+110/−17 lines, 6 filesbinary-addedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,10 @@+1.0.2 (2026-11-29)++  * Updated lots of documentation+  * Added genai policy documents+  * Fixed sample code formatting++ 1.0.1 (2025-09-05)    * Fixed build dependency issue with Stackage nightly snapshot
README.md view
@@ -8,28 +8,30 @@  ## Description -optparse-applicative is a fantastic library+`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.+between projects. It's a drop-in replacement for `optparse-applicative`. -In most CLI projects I almost always want:+In most CLI projects I almost always want some things beyond the basics:  - 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+- A helper to provide -h, --help+- A helper to provide --version, that outputs the name and version only+- A default of 100 for wrapping usage instead of the default of 80 - Some additional usage info below the generated switch usage+- Less boring boilerplate to paste from other projects  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:+A simple example using `optparse-applicative-dex`: -    {- # LANGUAGE OverloadedStrings #-}+    {-# LANGUAGE OverloadedStrings #-}      import Options.Applicative.Dex     import Paths_your_app (version)@@ -40,19 +42,79 @@     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")+      <*> switch ( short 'b' <> help "The b option, a switch" )      main :: IO ()     main = do       opts <- parseOpts' parser "header-info" "footer-info" version       print opts +The same behavior above with vanilla `optparse-applicative` +    {-# LANGUAGE OverloadedStrings #-}++    -- Note these library dependencies: optparse-applicative prettyprinter text++    import Data.Text.Lazy (Text, unpack)+    import Data.Version (Version, showVersion)+    import Options.Applicative+    import Paths_your_app (version)+    import Prettyprinter (pretty)+    import System.Environment (getProgName)++    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" )++    versionHelper :: String -> Version -> Parser (a -> a)+    versionHelper progName version' =+      infoOption (progName <> " " <> showVersion version') $ mconcat+      [ long "version"+      , help "Show version information"+      , hidden+      ]++    myParseOpts+      :: Parser a   -- ^ CLI arguments parser made with optparse-applicative API+      -> Text       -- ^ One-line app description for the usage header+      -> Text       -- ^ Content for usage footer (after switches)+      -> Version    -- ^ Application version+      -> IO a+    myParseOpts parser' headerContent footerContent version' = do+      pn <- getProgName+      customExecParser (prefs $ columns 100)+        $ info (parser' <**> helper <**> versionHelper pn version')+        (  header (pn <> " - " <> unpack headerContent)+        <> (footerDoc . Just . pretty $ footerContent)+        )++    main :: IO ()+    main = do+      opts <- myParseOpts parser "header-info" "footer-info" version+      print opts++ ## Getting source -Source code is available from codeberg at the [optparse-applicative-dex](https://codeberg.org/dinofp/optparse-applicative-dex) project page.+Source code is available from codeberg at the+[optparse-applicative-dex](https://codeberg.org/dinofp/optparse-applicative-dex)+project page. +Handy command to generate Haddock docs during development if using stack. This+constrains doc generation to modules in the library: +    $ stack haddock --no-haddock-deps++Note this project has a [generative AI/LLM policy](generative-ai-policy.md)++ ## Contact  Dino Morelli <dino@ui3.info>++[![Made by a human badge](doc/MadeByAHuman_01.png)](https://ko-fi.com/s/4662b19f61)+This work is hand-crafted with no LLM/AI involved
+ doc/MadeByAHuman_01.png view

binary file changed (absent → 1979 bytes)

+ generative-ai-policy.md view
@@ -0,0 +1,20 @@+# Generative AI Policy++This project **does not allow** contributions generated by large languages+models (LLMs) and chatbots. This ban includes tools like ChatGPT, Claude,+Copilot, DeepSeek, and Devin AI and it applies to all parts of the project,+including, but not limited to, code, documentation, issues, and artworks. We+are taking these steps due to:++* The potential negative influence of AI generated content on quality.+* Legal complications such as the inability to claim copyright and ensure+  others' licensing and copyright have not been violated.+* Ethical concerns including but not limited to those regarding intellectual+  property theft, environmental impact, externalities that primarily impact+  already-marginalized groups, devaluing labor for the purpose of concentrating+  power among the billionaire class, etc.++In the interest of reasonably accommodating our international community, an+exception applies purely for translating text in Issues, Discussions, and their+comments to English using dedicated machine translation tools like Google+Translate.
optparse-applicative-dex.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2  name: optparse-applicative-dex-version: 1.0.1+version: 1.0.2 synopsis: Extra functions for working with optparse-applicative description:   optparse-applicative is a fantastic library@@ -24,6 +24,8 @@   stack.yaml extra-doc-files:   CHANGELOG.md+  doc/MadeByAHuman_01.png+  generative-ai-policy.md  source-repository head   type: git
src/lib/Options/Applicative/Dex.hs view
@@ -1,18 +1,20 @@ {-|-optparse-applicative is a fantastic library+`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.+between projects. It's a drop-in replacement for `optparse-applicative`. -In most projects I almost always want:+In most CLI projects I almost always want some things beyond the basics:  - 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+- A helper to provide -h, --help+- A helper to provide --version, that outputs the name and version only+- A default of 100 for wrapping usage instead of the default of 80 - Some additional usage info below the generated switch usage+- Less boring boilerplate to paste from other projects  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@@ -21,7 +23,7 @@ A simple example:  @-{- # LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings #-}  import Options.Applicative.Dex import Paths_your_app (version)@@ -32,7 +34,7 @@ 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")+  <*> switch ( short 'b' <> help "The b option, a switch" )  main :: IO () main = do