X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FCommandLine.hs;h=455f7fd7a9416f0e417829ae9f6cad1020670c41;hb=0ee39f7100c4f7184cded8441e27849f0a123dce;hp=a61cc30e46b570a34f6541e68a39f1368a5a8677;hpb=6f0e6cbece7e1b1a3c6b43d19eb2f29088af981c;p=dead%2Flwn-epub.git diff --git a/src/CommandLine.hs b/src/CommandLine.hs index a61cc30..455f7fd 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. @@ -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)