From 4b41e11d6116c5552f396ea1cc261b95bfc81222 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 9 Jul 2023 16:23:40 +0200 Subject: Initial --- src/Optparse.hs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Optparse.hs (limited to 'src/Optparse.hs') 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 {..} -- cgit v1.2.3-70-g09d2