~yoctocell/flaskell

1acdc91fa01d2dd137ce84af01b159956b62031d — yoctocell 1 year, 10 months ago 0d7c062
Cli.hs: Add FIXME for stdin

Reading stdin in currently broken.
1 files changed, 14 insertions(+), 10 deletions(-)

M src/Flaskell/Cli.hs
M src/Flaskell/Cli.hs => src/Flaskell/Cli.hs +14 -10
@@ 7,17 7,17 @@ where
import           Flaskell.Parser
import           Flaskell.Ui

import Options.Applicative
import System.Exit
import           System.Environment (getArgs, getProgName)

import           Options.Applicative
import           System.Environment  (getArgs, getProgName)
import           System.Exit
import           System.IO           (getContents)

data Input = FileInput FilePath | StdInput

data Options = Options
  { version :: Bool
  , input :: Input }
  
  , input   :: Input }

versionNumber :: String
versionNumber = "0.1.0.0"



@@ 33,7 33,7 @@ stdInput = flag' StdInput
  (  long "stdin"
  <> short 'i'
  <> help "Read from stdin" )
  

cliArgs :: Parser Options
cliArgs = Options
          <$> switch


@@ 48,8 48,13 @@ parseCliArgs options = case options of
  (Options False (FileInput file)) -> do
    contents <- readFile file
    feedCards . getCards $ contents
  (Options False (StdInput)) -> putStrLn "stdin"
    
    -- FIXME hGetLine closed handle erro
  (Options False (StdInput)) -> do
    putStrLn "stdin"
    -- contents <- getContents
    -- length contents `seq` return ()
    -- feedCards . getCards $ contents

-- Take contents of a file and return a list of Flashcard
getCards :: String -> [Flashcard]
getCards contents =


@@ 58,7 63,6 @@ getCards contents =
  in
    zip hints answers

  
cli :: IO ()
cli = do
  parseCliArgs =<< execParser args