diff options
Diffstat (limited to 'src/Optparse.hs')
-rw-r--r-- | src/Optparse.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Optparse.hs b/src/Optparse.hs new file mode 100644 index 0000000..784bf81 --- /dev/null +++ b/src/Optparse.hs @@ -0,0 +1,31 @@ +{-# 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 {..} |