aboutsummaryrefslogtreecommitdiffhomepage
path: root/specification/app
diff options
context:
space:
mode:
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"