diff --git a/htest/Test/Ganeti/HTools/CLI.hs b/htest/Test/Ganeti/HTools/CLI.hs index 39e93da9a71868b6ae712d3e8743890342078e46..a9ae7435b39552fe5f8100b35a4b28b11f893518 100644 --- a/htest/Test/Ganeti/HTools/CLI.hs +++ b/htest/Test/Ganeti/HTools/CLI.hs @@ -119,8 +119,10 @@ case_wrong_arg = -- | Test that all binaries support some common options. case_stdopts :: Assertion case_stdopts = - mapM_ (\(name, (_, o, a)) -> checkEarlyExit defaultOptions name - (o ++ genericOpts) a) Program.personalities + mapM_ (\(name, (_, o, a)) -> do + o' <- o + checkEarlyExit defaultOptions name + (o' ++ genericOpts) a) Program.personalities testSuite "HTools/CLI" [ 'prop_parseISpec diff --git a/htools/Ganeti/HTools/Program.hs b/htools/Ganeti/HTools/Program.hs index fff678cbeb9b62b61688ce90c97609b5a5f128d7..e47a6bd77ec0467555be7cd5550330f9cf9b712e 100644 --- a/htools/Ganeti/HTools/Program.hs +++ b/htools/Ganeti/HTools/Program.hs @@ -39,7 +39,8 @@ import qualified Ganeti.HTools.Program.Hinfo as Hinfo -- | Supported binaries. personalities :: [(String, - (Options -> [String] -> IO (), [OptType], [ArgCompletion]))] + (Options -> [String] -> IO (), IO [OptType], + [ArgCompletion]))] personalities = [ ("hail", (Hail.main, Hail.options, Hail.arguments)) , ("hbal", (Hbal.main, Hbal.options, Hbal.arguments)) , ("hcheck", (Hcheck.main, Hcheck.options, Hcheck.arguments)) diff --git a/htools/Ganeti/HTools/Program/Hail.hs b/htools/Ganeti/HTools/Program/Hail.hs index c2f6473879e992c8e9ef4481224704cd579ce69f..adcddf9892e2705abf104d7e933558d00c5310ab 100644 --- a/htools/Ganeti/HTools/Program/Hail.hs +++ b/htools/Ganeti/HTools/Program/Hail.hs @@ -43,14 +43,15 @@ import Ganeti.HTools.ExtLoader (maybeSaveData, loadExternalData) import Ganeti.Utils -- | Options list and functions. -options :: [OptType] +options :: IO [OptType] options = - [ oPrintNodes - , oSaveCluster - , oDataFile - , oNodeSim - , oVerbose - ] + return + [ oPrintNodes + , oSaveCluster + , oDataFile + , oNodeSim + , oVerbose + ] -- | The list of arguments supported by the program. arguments :: [ArgCompletion] diff --git a/htools/Ganeti/HTools/Program/Hbal.hs b/htools/Ganeti/HTools/Program/Hbal.hs index c0d34f5dfaa49a9ba2878f4b720853b383defadd..aeeb2b48b3bf7ea8ef6e9ed9bab781fe6fec698d 100644 --- a/htools/Ganeti/HTools/Program/Hbal.hs +++ b/htools/Ganeti/HTools/Program/Hbal.hs @@ -62,35 +62,36 @@ import qualified Ganeti.Luxi as L import Ganeti.Jobs -- | Options list and functions. -options :: [OptType] +options :: IO [OptType] options = - [ oPrintNodes - , oPrintInsts - , oPrintCommands - , oDataFile - , oEvacMode - , oRapiMaster - , oLuxiSocket - , oIAllocSrc - , oExecJobs - , oGroup - , oMaxSolLength - , oVerbose - , oQuiet - , oOfflineNode - , oMinScore - , oMaxCpu - , oMinDisk - , oMinGain - , oMinGainLim - , oDiskMoves - , oSelInst - , oInstMoves - , oDynuFile - , oExTags - , oExInst - , oSaveCluster - ] + return + [ oPrintNodes + , oPrintInsts + , oPrintCommands + , oDataFile + , oEvacMode + , oRapiMaster + , oLuxiSocket + , oIAllocSrc + , oExecJobs + , oGroup + , oMaxSolLength + , oVerbose + , oQuiet + , oOfflineNode + , oMinScore + , oMaxCpu + , oMinDisk + , oMinGain + , oMinGainLim + , oDiskMoves + , oSelInst + , oInstMoves + , oDynuFile + , oExTags + , oExInst + , oSaveCluster + ] -- | The list of arguments supported by the program. arguments :: [ArgCompletion] diff --git a/htools/Ganeti/HTools/Program/Hcheck.hs b/htools/Ganeti/HTools/Program/Hcheck.hs index fb59094786c235920cacb103c76f69a9a200c1b4..d8b110092aa00e079157d2fb08a719a1edbdf97a 100644 --- a/htools/Ganeti/HTools/Program/Hcheck.hs +++ b/htools/Ganeti/HTools/Program/Hcheck.hs @@ -50,31 +50,32 @@ import Ganeti.HTools.Types import Ganeti.Utils -- | Options list and functions. -options :: [OptType] +options :: IO [OptType] options = - [ oDataFile - , oDiskMoves - , oDynuFile - , oEvacMode - , oExInst - , oExTags - , oIAllocSrc - , oInstMoves - , oLuxiSocket - , oMachineReadable - , oMaxCpu - , oMaxSolLength - , oMinDisk - , oMinGain - , oMinGainLim - , oMinScore - , oNoSimulation - , oOfflineNode - , oQuiet - , oRapiMaster - , oSelInst - , oVerbose - ] + return + [ oDataFile + , oDiskMoves + , oDynuFile + , oEvacMode + , oExInst + , oExTags + , oIAllocSrc + , oInstMoves + , oLuxiSocket + , oMachineReadable + , oMaxCpu + , oMaxSolLength + , oMinDisk + , oMinGain + , oMinGainLim + , oMinScore + , oNoSimulation + , oOfflineNode + , oQuiet + , oRapiMaster + , oSelInst + , oVerbose + ] -- | The list of arguments supported by the program. arguments :: [ArgCompletion] diff --git a/htools/Ganeti/HTools/Program/Hinfo.hs b/htools/Ganeti/HTools/Program/Hinfo.hs index 367bf0f20fbcc20eade9d135689bd09de724e3a9..d6140171bd511e52858c33afd9f2775a6360598c 100644 --- a/htools/Ganeti/HTools/Program/Hinfo.hs +++ b/htools/Ganeti/HTools/Program/Hinfo.hs @@ -48,18 +48,19 @@ import Ganeti.HTools.Loader import Ganeti.Utils -- | Options list and functions. -options :: [OptType] +options :: IO [OptType] options = - [ oPrintNodes - , oPrintInsts - , oDataFile - , oRapiMaster - , oLuxiSocket - , oIAllocSrc - , oVerbose - , oQuiet - , oOfflineNode - ] + return + [ oPrintNodes + , oPrintInsts + , oDataFile + , oRapiMaster + , oLuxiSocket + , oIAllocSrc + , oVerbose + , oQuiet + , oOfflineNode + ] -- | The list of arguments supported by the program. arguments :: [ArgCompletion] diff --git a/htools/Ganeti/HTools/Program/Hscan.hs b/htools/Ganeti/HTools/Program/Hscan.hs index d184e1ecbe33cc302bcbda27737fe56728e82777..ee6470651e1e0172dc3278d8ac7e48f9532c18c3 100644 --- a/htools/Ganeti/HTools/Program/Hscan.hs +++ b/htools/Ganeti/HTools/Program/Hscan.hs @@ -52,14 +52,15 @@ import Ganeti.Common import Ganeti.HTools.CLI -- | Options list and functions. -options :: [OptType] +options :: IO [OptType] options = - [ oPrintNodes - , oOutputDir - , oLuxiSocket - , oVerbose - , oNoHeaders - ] + return + [ oPrintNodes + , oOutputDir + , oLuxiSocket + , oVerbose + , oNoHeaders + ] -- | The list of arguments supported by the program. arguments :: [ArgCompletion] diff --git a/htools/Ganeti/HTools/Program/Hspace.hs b/htools/Ganeti/HTools/Program/Hspace.hs index 6dd4905032253e85a3ff124990ea276449939a79..a785d5b86b3dbbcc971c2fae2f17d1cce9ae9f98 100644 --- a/htools/Ganeti/HTools/Program/Hspace.hs +++ b/htools/Ganeti/HTools/Program/Hspace.hs @@ -53,27 +53,28 @@ import Ganeti.HTools.Loader import Ganeti.Utils -- | Options list and functions. -options :: [OptType] +options :: IO [OptType] options = - [ oPrintNodes - , oDataFile - , oDiskTemplate - , oSpindleUse - , oNodeSim - , oRapiMaster - , oLuxiSocket - , oIAllocSrc - , oVerbose - , oQuiet - , oOfflineNode - , oMachineReadable - , oMaxCpu - , oMaxSolLength - , oMinDisk - , oStdSpec - , oTieredSpec - , oSaveCluster - ] + return + [ oPrintNodes + , oDataFile + , oDiskTemplate + , oSpindleUse + , oNodeSim + , oRapiMaster + , oLuxiSocket + , oIAllocSrc + , oVerbose + , oQuiet + , oOfflineNode + , oMachineReadable + , oMaxCpu + , oMaxSolLength + , oMinDisk + , oStdSpec + , oTieredSpec + , oSaveCluster + ] -- | The list of arguments supported by the program. arguments :: [ArgCompletion] diff --git a/htools/htools.hs b/htools/htools.hs index 35dc99d74a0cf896357750e08d5959753c902f73..1b491e2b41f22929b7c4ae4a3b7a76fe5f04b749 100644 --- a/htools/htools.hs +++ b/htools/htools.hs @@ -56,6 +56,7 @@ main = do Nothing -> usage name Just (fn, options, arguments) -> do cmd_args <- getArgs - (opts, args) <- parseOpts cmd_args name (options ++ genericOpts) + real_options <- options + (opts, args) <- parseOpts cmd_args name (real_options ++ genericOpts) arguments fn opts args