1 {-# LANGUAGE DoAndIfThenElse #-}
5 import System.Directory (doesFileExist)
12 import CommandLine (show_help)
13 import Configuration (Cfg(..), get_cfg)
14 import LWN.Article (real_article_path)
15 import LWN.HTTP (get_login_cookie)
16 import LWN.Page (epublish, page_from_url)
19 -- | If we're given an empty path, return a handle to
20 -- 'stdout'. Otherwise, open the given file and return a read/write
22 get_output_handle :: FilePath -> IO Handle
23 get_output_handle path =
27 openBinaryFile path WriteMode
30 argument_is_file :: Cfg -> IO Bool
31 argument_is_file cfg = do
32 path <- real_article_path (article cfg)
38 aif <- argument_is_file cfg'
40 False -> get_login_cookie cfg'
42 page <- page_from_url cfg (article cfg)
45 output_handle <- get_output_handle (output cfg)
46 epublish p output_handle