Furthermore, a few messages have their capitalisation changed (fixed).
Signed-off-by: Helga Velroyen <helgav@google.com>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
# extra arguments
./htest/hspace unexpected-argument
>>>2
-Error: this program doesn't take any arguments.
+Error: This program doesn't take any arguments.
>>>=1
./htest/hbal unexpected-argument
>>>2
-Error: this program doesn't take any arguments.
+Error: This program doesn't take any arguments.
>>>=1
./htest/hinfo unexpected-argument
>>>2
-Error: this program doesn't take any arguments.
+Error: This program doesn't take any arguments.
>>>=1
./htest/hcheck unexpected-argument
>>>2
-Error: this program doesn't take any arguments.
+Error: This program doesn't take any arguments.
>>>=1
exInsts = optExInst opts
exitWhen (length allSet > 1) "Only one of the rapi, luxi, and data\
- \ files options should be given"
+ \ files options should be given."
util_contents <- maybe (return "") readFile (optDynuFile opts)
util_data <- exitIfBad "can't parse utilisation data" .
import Control.Monad
import Text.JSON (JSObject, JSValue(JSArray),
makeObj, encodeStrict, decodeStrict, fromJSObject, showJSON)
-import System.Exit
-import System.IO
import Ganeti.BasicTypes
import qualified Ganeti.HTools.Cluster as Cluster
import Ganeti.HTools.Loader
import Ganeti.HTools.Types
import Ganeti.JSON
+import Ganeti.Utils
{-# ANN module "HLint: ignore Eta reduce" #-}
"-" -> getContents
_ -> readFile fp
case parseData input_data of
- Bad err -> do
- hPutStrLn stderr $ "Error: " ++ err
- exitWith $ ExitFailure 1
+ Bad err -> exitErr err
Ok (fix_msgs, rq) -> maybeShowWarnings fix_msgs >> return rq
-- | Main iallocator pipeline.
import Control.Monad
import Data.Maybe (fromMaybe, isJust)
import System.IO
-import System.Exit
import qualified Ganeti.HTools.Cluster as Cluster
import Ganeti.HTools.IAlloc
import Ganeti.HTools.Loader (Request(..), ClusterData(..))
import Ganeti.HTools.ExtLoader (maybeSaveData, loadExternalData)
+import Ganeti.Utils
-- | Options list and functions.
options :: [OptType]
wrapReadRequest :: Options -> [String] -> IO Request
wrapReadRequest opts args = do
- when (null args) $ do
- hPutStrLn stderr "Error: this program needs an input file."
- exitWith $ ExitFailure 1
+ when (null args) $ exitErr "This program needs an input file."
r1 <- readRequest (head args)
if isJust (optDataFile opts) || (not . null . optNodeSim) opts
hPutStrLn stderr "Found multiple node groups:"
mapM_ (hPutStrLn stderr . (" " ++) . Group.name .
flip Container.find gl . fst) ngroups
- hPutStrLn stderr "Aborting."
- exitWith $ ExitFailure 1
+ exitErr "Aborting."
case optGroup opts of
Nothing -> do
hPutStrLn stderr $ "Node group " ++ g ++
" not found. Node group list is:"
mapM_ (hPutStrLn stderr . (" " ++) . Group.name ) (Container.elems gl)
- hPutStrLn stderr "Aborting."
- exitWith $ ExitFailure 1
+ exitErr "Aborting."
Just grp ->
case lookup (Group.idx grp) ngroups of
Nothing ->
-- | Main function.
main :: Options -> [String] -> IO ()
main opts args = do
- unless (null args) $ do
- hPutStrLn stderr "Error: this program doesn't take any arguments."
- exitWith $ ExitFailure 1
+ unless (null args) $ exitErr "This program doesn't take any arguments."
let verbose = optVerbose opts
shownodes = optShowNodes opts
import Control.Monad
import Data.List (transpose)
import System.Exit
-import System.IO
import Text.Printf (printf)
import qualified Ganeti.HTools.Container as Container
import Ganeti.HTools.ExtLoader
import Ganeti.HTools.Loader
import Ganeti.HTools.Types
+import Ganeti.Utils
-- | Options list and functions.
options :: [OptType]
-- | Main function.
main :: Options -> [String] -> IO ()
main opts args = do
- unless (null args) $ do
- hPutStrLn stderr "Error: this program doesn't take any arguments."
- exitWith $ ExitFailure 1
+ unless (null args) $ exitErr "This program doesn't take any arguments."
let verbose = optVerbose opts
machineread = optMachineReadable opts
import Control.Monad
import Data.List
-import System.Exit
import System.IO
import Text.Printf (printf)
-- | Main function.
main :: Options -> [String] -> IO ()
main opts args = do
- unless (null args) $ do
- hPutStrLn stderr "Error: this program doesn't take any arguments."
- exitWith $ ExitFailure 1
+ unless (null args) $ exitErr "This program doesn't take any arguments."
let verbose = optVerbose opts
shownodes = optShowNodes opts
-- | Main function.
main :: Options -> [String] -> IO ()
main opts args = do
- exitUnless (null args) "this program doesn't take any arguments"
+ exitUnless (null args) "This program doesn't take any arguments."
let verbose = optVerbose opts
machine_r = optMachineReadable opts
-- | Unwraps a 'Result', exiting the program if it is a 'Bad' value,
-- otherwise returning the actual contained value.
exitIfBad :: String -> Result a -> IO a
-exitIfBad msg (Bad s) = do
- hPutStrLn stderr $ "Error: " ++ msg ++ ": " ++ s
- exitWith (ExitFailure 1)
+exitIfBad msg (Bad s) = exitErr (msg ++ ": " ++ s)
exitIfBad _ (Ok v) = return v
-- | Exits immediately with an error message.
exitErr :: String -> IO a
exitErr errmsg = do
- hPutStrLn stderr $ "Error: " ++ errmsg ++ "."
+ hPutStrLn stderr $ "Error: " ++ errmsg
exitWith (ExitFailure 1)
-- | Exits with an error message if the given boolean condition if true.
import Data.Char (toLower)
import Prelude hiding (catch)
import System.Environment
-import System.Exit
import System.IO
import System.IO.Error (isDoesNotExistError)
hPutStrLn stderr "This program must be installed under one of the following\
\ names:"
mapM_ (hPutStrLn stderr . (" - " ++) . fst) personalities
- hPutStrLn stderr "Please either rename/symlink the program or set\n\
- \the environment variable HTOOLS to the desired role."
- exitWith $ ExitFailure 1
+ exitErr "Please either rename/symlink the program or set\n\
+ \the environment variable HTOOLS to the desired role."
main :: IO ()
main = do
usage :: IO ()
usage = do
prog <- getProgName
- hPutStrLn stderr $ "Usage: " ++ prog ++ " delay node..."
- exitWith $ ExitFailure 1
+ exitErr "Usage: " ++ prog ++ " delay node..."
main :: IO ()
main = do