sbergot / ArgParser

BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

Added appVersion setter and flipped setters #6

Closed agustinmista closed 3 months ago

agustinmista commented 7 years ago

I've added the app version setter setAppVersion that was missing for some reason I couln't find.

I've also made a few changes that helps to write the application strings easily when using mkSubParser: Adding a flipped version of setAppDescr, setAppEpilog and setAppVersion allows to use infix <$> to write something like:

-- This is my main cli parser
mainParser :: IO (CmdLnInterface MyType)
mainParser = mkSubParser 
    [ ("subaction1", mkDefaultApp subAction1Parser "subaction1") 
    , ("subaction2", mkDefaultApp subAction2Parser "subaction2") ]

-- and the main parser including descriptive strings can be written like this
parseCli :: IO (CmdLnInterface MyType)
parseCli = setVersion "1.2.3"
       <$> setDescr "My application description"
       <$> setEpilog "My application epilog"
       <$> mainParser

Which I found clearer to understand than the current implementation.

I really hope you found this changes useful.

Regards. Agustín.