{-# LANGUAGE ApplicativeDo #-} {-# LANGUAGE RecordWildCards #-} module Optparse ( Options(..), parseOptions, ) where import Options.Applicative data Options = Options { optsFpath1 :: FilePath , optsFpath2 :: Maybe FilePath } deriving (Show) parseOptions :: IO Options parseOptions = execParser $ info (pOptions <**> helper) ( fullDesc <> progDesc "View, edit and diff binary files" <> header "hhexed - haskell hex editor" ) pOptions :: Parser Options pOptions = do optsFpath1 <- strArgument (metavar "FILE" <> help "File to display") optsFpath2 <- optional (strArgument (metavar "FILE2" <> help "File to diff against (optional)")) return Options {..}