]> gitweb.michael.orlitzky.com - dead/lwn-epub.git/blobdiff - src/CommandLine.hs
Switch from a FilePath to a CookieJar in the config.
[dead/lwn-epub.git] / src / CommandLine.hs
index a61cc30e46b570a34f6541e68a39f1368a5a8677..2df29a57dfd9a10635d46c75af20ccd47f66ae72 100644 (file)
@@ -1,6 +1,10 @@
 {-# LANGUAGE DeriveDataTypeable #-}
 
-module CommandLine (Args(..), apply_args)
+module CommandLine (
+  Args(..),
+  apply_args,
+  program_name,
+  show_help)
 where
 
 -- Get the version from Cabal.
@@ -36,7 +40,8 @@ import ExitCodes
 
 
 data Args =
-  Args { output :: FilePath,
+  Args { full_stories :: Bool,
+         output :: FilePath,
          article :: String }
   deriving   (Show, Data, Typeable)
 
@@ -45,7 +50,7 @@ description :: String
 description = "Convert LWN articles to EPUB format."
 
 program_name :: String
-program_name = "lwn_epub"
+program_name = "lwn-epub"
 
 lwn_epub_summary :: String
 lwn_epub_summary =
@@ -54,11 +59,15 @@ lwn_epub_summary =
 output_help :: String
 output_help = "Output file, defaults to stdout"
 
+full_stories_help :: String
+full_stories_help = "Replace \"Full Story\" links with their content"
+
 arg_spec :: Mode (CmdArgs Args)
 arg_spec = cmdArgsMode $
              Args {
-               output = def  &= typFile &= help output_help,
-               article = def &= argPos 0 &= typ "ARTICLE"
+               full_stories = def &= help full_stories_help,
+               output       = def &= typFile  &= help output_help,
+               article      = def &= argPos 0 &= typ "ARTICLE"
              }
              &= program program_name
              &= summary lwn_epub_summary
@@ -71,6 +80,9 @@ is_missing_arg_error s =
   startswith "Requires at least" s
 
 
+show_help :: IO (CmdArgs Args)
+show_help = withArgs ["--help"] parse_args
+
 parse_args :: IO (CmdArgs Args)
 parse_args = do
   x <- getArgs
@@ -80,7 +92,7 @@ parse_args = do
       Left err ->
         if (is_missing_arg_error err) then
           -- Disregard the error message, show help instead.
-          withArgs ["--help"] parse_args
+          show_help
         else do
           hPutStrLn stderr err
           exitWith (ExitFailure exit_args_parse_failed)