1
1
mirror of https://github.com/Yvee1/hascard.git synced 2024-10-26 07:41:15 +03:00

Add possibility to provide card in CLI argument

This commit is contained in:
Steven van den Broek 2020-07-17 22:31:32 +02:00
parent f33dba7b37
commit e2b93133fe

View File

@ -4,16 +4,25 @@ import Lib (runBrickFlashcards)
import BrickHelpers
import Brick
import Brick.Widgets.Center
import CardUI
import Control.Exception (displayException, try)
import Control.Monad.IO.Class
import Data.Functor (($>))
import Parser
import System.Environment (getArgs)
import System.Process (runCommand)
main :: IO ()
main = do
_ <- runCommand "echo \\\\e[5 q"
runBrickFlashcards
-- test :: Widget ()
-- test = hCenter $ myStrWrap "Heey, this is a very long string of text, well maybe not that long... but pretty long in any case."
-- main :: IO ()
-- main = simpleMain test
_ <- runCommand "echo -n \\\\e[5 q"
args <- getArgs
if null args
then runBrickFlashcards
else do
strOrExc <- liftIO (try (readFile (head args)) :: IO (Either IOError String))
case strOrExc of
Left exc -> putStr (displayException exc)
Right str -> case parseCards str of
Left parseError -> print parseError
Right result -> runCardUI result $> ()