Improve the error message for command line errors
authorIustin Pop <iustin@google.com>
Wed, 19 Aug 2009 11:02:52 +0000 (13:02 +0200)
committerIustin Pop <iustin@google.com>
Wed, 19 Aug 2009 11:03:58 +0000 (13:03 +0200)
Instead of using ioError . userError, we format the error ourselves.
This is nicer - no ‘)’ at the end of the output.

Ganeti/HTools/CLI.hs

index 1672435..5bd47ad 100644 (file)
@@ -296,8 +296,10 @@ parseOpts argv progname options =
                      os arch
               exitWith ExitSuccess
             return resu
-      (_, _, errs) ->
-          ioError (userError (concat errs ++ usageHelp progname options))
+      (_, _, errs) -> do
+        hPutStrLn stderr $ "Command line error: "  ++ concat errs
+        hPutStrLn stderr $ usageHelp progname options
+        exitWith $ ExitFailure 2
 
 -- | Parse the environment and return the node\/instance names.
 --