dictfr/Main.hs

24 lines
644 B
Haskell

module Main where
import System.Environment
import Download
import ParseHtml
import qualified Data.Text.Lazy.Encoding as E
import qualified Data.ByteString.Lazy.Char8 as L
main :: IO ()
main = getArgs >>= parse
parse [] = usage
parse ("-d":[]) = usage
parse ("-d":n:[]) = usage
parse ("-d":n:fs) = do
htmlResult <- downloadHtmlDef n (head fs)
printDef (E.decodeUtf8 htmlResult)
parse fs = do
htmlResult <- downloadHtmlAvailableDef (head fs)
printDifferentDef (E.decodeUtf8 htmlResult)
usage = putStrLn "Usage: dictfr [options] [word]\n\nOPTIONS:\n-d id the definition id for the word"