aboutsummaryrefslogtreecommitdiffhomepage
path: root/specification/app
diff options
context:
space:
mode:
authorFrédéric Menou <frederic.menou@fretlink.com>2016-12-08 10:19:15 +0200
committerIsmaël Bouya <ismael.bouya@fretlink.com>2022-05-17 18:01:51 +0200
commita9d77a20008efe82862cc1adbfa7a6d4f09f8ff7 (patch)
treeadf3186fdccaeef19151026cdfbd38a530cf9ecb /specification/app
downloadedi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.tar.gz
edi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.tar.zst
edi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.zip
Release code as open sourceHEADmaster
Diffstat (limited to 'specification/app')
-rw-r--r--specification/app/Main.hs36
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 @@
1module Main
2 ( main
3 ) where
4
5import Text.Edifact.Common (parseFull)
6import Text.Edifact.D96A (messageIFCSUM, messageDESADV)
7import Text.Edifact.Inspect (inspect)
8import Text.Edifact.Types (Value)
9
10import Control.Monad ((>=>))
11import qualified Data.Text.IO as TIO (putStrLn, readFile)
12import System.Environment (getArgs)
13
14main :: IO ()
15main = getArgs >>= dispatch
16
17dispatch :: [String] -> IO ()
18dispatch ("ifcsum" : filename : _) = readIFCSUM filename
19dispatch ("desadv" : filename : _) = readDESADV filename
20dispatch _ = help
21
22readIFCSUM :: FilePath -> IO ()
23readIFCSUM =
24 let display = either print (TIO.putStrLn . inspect)
25 in TIO.readFile >=> display . parseFull messageIFCSUM
26
27readDESADV :: FilePath -> IO ()
28readDESADV =
29 let display = either print (TIO.putStrLn . inspect)
30 in TIO.readFile >=> display . parseFull messageDESADV
31
32help :: IO ()
33help = 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"