X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Flwn-epub.git;a=blobdiff_plain;f=src%2FCommandLine.hs;h=7afc7f1589a84c78a53fcf45493f7d0caad0be1f;hp=a61cc30e46b570a34f6541e68a39f1368a5a8677;hb=823c2383e7bfd649b2213faecd1586fa6c2b5473;hpb=6f0e6cbece7e1b1a3c6b43d19eb2f29088af981c diff --git a/src/CommandLine.hs b/src/CommandLine.hs index a61cc30..7afc7f1 100644 --- a/src/CommandLine.hs +++ b/src/CommandLine.hs @@ -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. @@ -45,7 +49,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 = @@ -71,6 +75,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 +87,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)