diff options
author | Frédéric Menou <frederic.menou@fretlink.com> | 2016-12-08 10:19:15 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2022-05-17 18:01:51 +0200 |
commit | a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7 (patch) | |
tree | adf3186fdccaeef19151026cdfbd38a530cf9ecb /specification/app | |
download | edi-parser-master.tar.gz edi-parser-master.tar.zst edi-parser-master.zip |
Diffstat (limited to 'specification/app')
-rw-r--r-- | specification/app/Main.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/specification/app/Main.hs b/specification/app/Main.hs new file mode 100644 index 0000000..1f2ba80 --- /dev/null +++ b/specification/app/Main.hs | |||
@@ -0,0 +1,36 @@ | |||
1 | module Main | ||
2 | ( main | ||
3 | ) where | ||
4 | |||
5 | import Text.Edifact.Common (parseFull) | ||
6 | import Text.Edifact.D96A (messageIFCSUM, messageDESADV) | ||
7 | import Text.Edifact.Inspect (inspect) | ||
8 | import Text.Edifact.Types (Value) | ||
9 | |||
10 | import Control.Monad ((>=>)) | ||
11 | import qualified Data.Text.IO as TIO (putStrLn, readFile) | ||
12 | import System.Environment (getArgs) | ||
13 | |||
14 | main :: IO () | ||
15 | main = getArgs >>= dispatch | ||
16 | |||
17 | dispatch :: [String] -> IO () | ||
18 | dispatch ("ifcsum" : filename : _) = readIFCSUM filename | ||
19 | dispatch ("desadv" : filename : _) = readDESADV filename | ||
20 | dispatch _ = help | ||
21 | |||
22 | readIFCSUM :: FilePath -> IO () | ||
23 | readIFCSUM = | ||
24 | let display = either print (TIO.putStrLn . inspect) | ||
25 | in TIO.readFile >=> display . parseFull messageIFCSUM | ||
26 | |||
27 | readDESADV :: FilePath -> IO () | ||
28 | readDESADV = | ||
29 | let display = either print (TIO.putStrLn . inspect) | ||
30 | in TIO.readFile >=> display . parseFull messageDESADV | ||
31 | |||
32 | help :: IO () | ||
33 | help = do | ||
34 | putStrLn "ifcsum <file> : inspect IFCSUM file for revision D96A" | ||
35 | putStrLn "desadv <file> : inspect DESADV file for revision D96A" | ||
36 | putStrLn "-h|--help : this message" | ||