Skip to content

Commit 8151dfb

Browse files
committed
Command line parsing
1 parent 855eaa1 commit 8151dfb

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed
Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
{-# LANGUAGE RecordWildCards #-}
3+
14
module Main where
25

36
import Data.ByteString.Lazy as BSL
47
import LeiosEvents
58
import Lib
6-
7-
logFile :: FilePath
8-
logFile = "leios-trace.log"
9+
import Options.Applicative
910

1011
main :: IO ()
11-
main = BSL.readFile logFile >>= print . verifyTrace . decodeJSONL
12+
main =
13+
do
14+
Command{..} <- execParser commandParser
15+
BSL.readFile logFile >>= print . verifyTrace . decodeJSONL
16+
17+
newtype Command = Command
18+
{ logFile :: FilePath
19+
}
20+
deriving (Eq, Ord, Read, Show)
21+
22+
commandParser :: ParserInfo Command
23+
commandParser =
24+
info (com <**> helper) $
25+
fullDesc
26+
<> progDesc "Short Leios trace verifier"
27+
<> header "parser - a Short Leios trace verifier"
28+
where
29+
com =
30+
Command
31+
<$> strOption
32+
( long "trace-file"
33+
<> help "Short Leios simulation trace log file"
34+
)

leios-trace-verifier/hs-src/trace-parser.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ executable parser
3636
, bytestring
3737
, leios-trace-hs
3838
, trace-parser
39+
, optparse-applicative
3940

4041
default-language: Haskell2010
4142
ghc-options: -Wall

0 commit comments

Comments
 (0)