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:
parent
f33dba7b37
commit
e2b93133fe
25
app/Main.hs
25
app/Main.hs
@ -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 $> ()
|
||||
|
Loading…
Reference in New Issue
Block a user