dictfr/Main.hs

25 lines
682 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)
let n' = read n :: Int
printDef (E.decodeUtf8 htmlResult) n'
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"