summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-11-10 11:57:08 +0100
committerEugen Wissner <belka@caraus.de>2023-11-10 11:57:08 +0100
commit82ecf51fea496726ab4643a88819ae3894d070a7 (patch)
treea7bbe50d2d5e985b630e01630cb8a02ea65c0c9e /app
parent57478f83625c885a3c5fdfdc84450eee9a3b5b1d (diff)
downloadfountainhead-82ecf51fea496726ab4643a88819ae3894d070a7.tar.gz
Add the PDF generator snippets
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 24e7a32..cc2c11d 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -16,10 +16,11 @@ import Graphics.Fountainhead.Parser
)
import Graphics.Fountainhead.TrueType (FontDirectory(..), TableDirectory(..))
import System.Environment (getArgs)
+import System.Exit (exitWith)
+import GHC.IO.Exception (ExitCode(..))
-fontMain :: IO ()
-fontMain = do
- fontFile <- head <$> getArgs
+fontMain :: FilePath -> IO ()
+fontMain fontFile = do
ttfContents <- ByteString.readFile fontFile
let initialState = Megaparsec.State
@@ -43,4 +44,9 @@ fontMain = do
Right x -> print x
main :: IO ()
-main = fontMain
+main = do
+ programArguments <- getArgs
+ case programArguments of
+ [fontFile] -> fontMain fontFile
+ _ -> putStrLn "The program expects exactly one argument, the font file path."
+ >> exitWith (ExitFailure 2)