module Main where

import Crawler

import System.Exit(exitFailure, exitSuccess)
import System.Environment(getArgs)
import Network.URI(parseURI)


main :: IO a
main = do
  args <- getArgs
  case args of
    []  -> print ("must supply uri"  :: String) >> exitFailure
    u:_ -> case (parseURI u) of
      Nothing -> print ("invalid uri" :: String) >> exitFailure
      Just uri -> visitPage prettyPrint uri >> exitSuccess
