From a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Menou?= Date: Thu, 8 Dec 2016 10:19:15 +0200 Subject: Release code as open source --- specification/app/Main.hs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 specification/app/Main.hs (limited to 'specification/app') 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 @@ +module Main + ( main + ) where + +import Text.Edifact.Common (parseFull) +import Text.Edifact.D96A (messageIFCSUM, messageDESADV) +import Text.Edifact.Inspect (inspect) +import Text.Edifact.Types (Value) + +import Control.Monad ((>=>)) +import qualified Data.Text.IO as TIO (putStrLn, readFile) +import System.Environment (getArgs) + +main :: IO () +main = getArgs >>= dispatch + +dispatch :: [String] -> IO () +dispatch ("ifcsum" : filename : _) = readIFCSUM filename +dispatch ("desadv" : filename : _) = readDESADV filename +dispatch _ = help + +readIFCSUM :: FilePath -> IO () +readIFCSUM = + let display = either print (TIO.putStrLn . inspect) + in TIO.readFile >=> display . parseFull messageIFCSUM + +readDESADV :: FilePath -> IO () +readDESADV = + let display = either print (TIO.putStrLn . inspect) + in TIO.readFile >=> display . parseFull messageDESADV + +help :: IO () +help = do + putStrLn "ifcsum : inspect IFCSUM file for revision D96A" + putStrLn "desadv : inspect DESADV file for revision D96A" + putStrLn "-h|--help : this message" -- cgit v1.2.3