1 {-# LANGUAGE DoAndIfThenElse #-}
5 import Control.Concurrent.ParallelIO (stopGlobalPool)
6 import System.Directory (doesFileExist)
13 import CommandLine (show_help)
14 import Configuration (Cfg(..), get_cfg)
15 import LWN.Article (real_article_path)
16 import LWN.HTTP (get_login_cookie)
17 import LWN.Page (epublish, page_from_url)
20 -- | If we're given an empty path, return a handle to
21 -- 'stdout'. Otherwise, open the given file and return a read/write
23 get_output_handle :: FilePath -> IO Handle
24 get_output_handle path =
28 openBinaryFile path WriteMode
31 argument_is_file :: Cfg -> IO Bool
32 argument_is_file cfg = do
33 path <- real_article_path (article cfg)
39 aif <- argument_is_file cfg'
41 False -> get_login_cookie cfg'
43 page <- page_from_url cfg (article cfg)
46 output_handle <- get_output_handle (output cfg)
47 epublish p output_handle
52 -- Necessary, for some reason.