X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Flwn-epub.git;a=blobdiff_plain;f=src%2FCommandLine.hs;h=0a3117073c220552ff2eaf186e0f74945363ff33;hp=455f7fd7a9416f0e417829ae9f6cad1020670c41;hb=95784f57c7cdd5f91c4fca86c11165723109f2a9;hpb=ebedcdb6b1b8925dcfb5700d076f25743fac8645 diff --git a/src/CommandLine.hs b/src/CommandLine.hs index 455f7fd..0a31170 100644 --- a/src/CommandLine.hs +++ b/src/CommandLine.hs @@ -40,7 +40,8 @@ import ExitCodes data Args = - Args { output :: FilePath, + Args { full_stories :: Bool, + output :: FilePath, article :: String } deriving (Show, Data, Typeable) @@ -49,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 = @@ -58,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 @@ -75,8 +80,8 @@ is_missing_arg_error s = startswith "Requires at least" s -show_help :: IO (CmdArgs Args) -show_help = withArgs ["--help"] parse_args +show_help :: IO Args +show_help = withArgs ["--help"] apply_args parse_args :: IO (CmdArgs Args) parse_args = do @@ -86,8 +91,9 @@ parse_args = do Right result -> return result Left err -> if (is_missing_arg_error err) then - -- Disregard the error message, show help instead. - show_help + -- Disregard the error message, show help instead. We can't + -- reuse show_help here because of its return type. + withArgs ["--help"] parse_args else do hPutStrLn stderr err exitWith (ExitFailure exit_args_parse_failed)