summaryrefslogtreecommitdiff
path: root/src/Optparse.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2023-07-09 16:23:40 +0200
committerTom Smeding <tom@tomsmeding.com>2023-07-09 16:23:40 +0200
commit4b41e11d6116c5552f396ea1cc261b95bfc81222 (patch)
treed7d069983e5ac912a8c15d840f6f1ff471a73d07 /src/Optparse.hs
InitialHEADmaster
Diffstat (limited to 'src/Optparse.hs')
-rw-r--r--src/Optparse.hs31
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 {..}