diff --git a/htest/Test/Ganeti/HTools/CLI.hs b/htest/Test/Ganeti/HTools/CLI.hs index 468ca56f68950c0510a32adf05c35869f2e814f0..78b6fa549bad6bbe679e127fc839ed2caa7ac07a 100644 --- a/htest/Test/Ganeti/HTools/CLI.hs +++ b/htest/Test/Ganeti/HTools/CLI.hs @@ -118,8 +118,8 @@ case_wrong_arg = -- | Test that all binaries support some common options. case_stdopts :: Assertion case_stdopts = - mapM_ (\(name, (_, o)) -> checkEarlyExit defaultOptions name o) - Program.personalities + mapM_ (\(name, (_, o)) -> checkEarlyExit defaultOptions name + (o ++ genericOpts)) Program.personalities testSuite "HTools/CLI" [ 'prop_parseISpec diff --git a/htools/Ganeti/Daemon.hs b/htools/Ganeti/Daemon.hs index f54a8cca6fecaff757f766cb6c1598a174ddab4a..a3330d7846a0f3ae19854090eaf7f9bca8856e7d 100644 --- a/htools/Ganeti/Daemon.hs +++ b/htools/Ganeti/Daemon.hs @@ -149,11 +149,17 @@ oSyslogUsage = Option "" ["syslog"] \messages); one of 'no', 'yes' or 'only' [" ++ C.syslogUsage ++ "]") +-- | Generic options. +genericOpts :: [OptType] +genericOpts = [ oShowHelp + , oShowVer + ] + -- | Small wrapper over getArgs and 'parseOpts'. parseArgs :: String -> [OptType] -> IO (DaemonOptions, [String]) parseArgs cmd options = do cmd_args <- getArgs - parseOpts defaultOptions cmd_args cmd options + parseOpts defaultOptions cmd_args cmd $ options ++ genericOpts -- * Daemon-related functions -- | PID file mode. diff --git a/htools/Ganeti/HTools/CLI.hs b/htools/Ganeti/HTools/CLI.hs index e4580136d5d2703477ac9a055d670345440002ee..4c03c25b3948f212acf36ef0686d67a1607e799f 100644 --- a/htools/Ganeti/HTools/CLI.hs +++ b/htools/Ganeti/HTools/CLI.hs @@ -80,6 +80,7 @@ module Ganeti.HTools.CLI , oStdSpec , oTieredSpec , oVerbose + , genericOpts ) where import Control.Monad @@ -434,6 +435,12 @@ oVerbose = Option "v" ["verbose"] (NoArg (\ opts -> Ok opts { optVerbose = optVerbose opts + 1 })) "increase the verbosity level" +-- | Generic options. +genericOpts :: [GenericOptType Options] +genericOpts = [ oShowVer + , oShowHelp + ] + -- * Functions -- | Wrapper over 'Common.parseOpts' with our custom options. diff --git a/htools/Ganeti/HTools/Program/Hail.hs b/htools/Ganeti/HTools/Program/Hail.hs index e701777e1f275a54c49f8ceb3c4d58a79453c532..3bc5e2c6a3217bbb6b79a5e5d4c69295a71b5d33 100644 --- a/htools/Ganeti/HTools/Program/Hail.hs +++ b/htools/Ganeti/HTools/Program/Hail.hs @@ -45,8 +45,6 @@ options = , oDataFile , oNodeSim , oVerbose - , oShowVer - , oShowHelp ] wrapReadRequest :: Options -> [String] -> IO Request diff --git a/htools/Ganeti/HTools/Program/Hbal.hs b/htools/Ganeti/HTools/Program/Hbal.hs index 8dc5bdd17d9b322b208c5a398339eaa1d1e546c7..dc103d3a2abf9af9283a447a4dfb7a1846e9fd37 100644 --- a/htools/Ganeti/HTools/Program/Hbal.hs +++ b/htools/Ganeti/HTools/Program/Hbal.hs @@ -86,8 +86,6 @@ options = , oExTags , oExInst , oSaveCluster - , oShowVer - , oShowHelp ] {- | Start computing the solution at the given depth and recurse until diff --git a/htools/Ganeti/HTools/Program/Hcheck.hs b/htools/Ganeti/HTools/Program/Hcheck.hs index ac47da2d81eeff439204feb803a99d61c9901712..a400d7faf01976efb891f7b92cd07baf65176766 100644 --- a/htools/Ganeti/HTools/Program/Hcheck.hs +++ b/htools/Ganeti/HTools/Program/Hcheck.hs @@ -68,8 +68,6 @@ options = , oQuiet , oRapiMaster , oSelInst - , oShowHelp - , oShowVer , oVerbose ] diff --git a/htools/Ganeti/HTools/Program/Hinfo.hs b/htools/Ganeti/HTools/Program/Hinfo.hs index e98382b4ac669f750ef667f416581b0b95c9b291..37f5bba1a863647679f140085cecde0f9eb764d5 100644 --- a/htools/Ganeti/HTools/Program/Hinfo.hs +++ b/htools/Ganeti/HTools/Program/Hinfo.hs @@ -55,8 +55,6 @@ options = , oVerbose , oQuiet , oOfflineNode - , oShowVer - , oShowHelp ] -- | Group information data-type. diff --git a/htools/Ganeti/HTools/Program/Hscan.hs b/htools/Ganeti/HTools/Program/Hscan.hs index b83cc57fc622358c735763aa87f7bae79400d535..44a9559232e88a9ab8c89f73f1c37459d698c734 100644 --- a/htools/Ganeti/HTools/Program/Hscan.hs +++ b/htools/Ganeti/HTools/Program/Hscan.hs @@ -54,8 +54,6 @@ options = , oLuxiSocket , oVerbose , oNoHeaders - , oShowVer - , oShowHelp ] -- | Return a one-line summary of cluster state. diff --git a/htools/Ganeti/HTools/Program/Hspace.hs b/htools/Ganeti/HTools/Program/Hspace.hs index 3cfc2f8df2c4e78f1c9c1b5add3f37346a279ac1..960d4fd4bdc4d39e2c28c3f4230b4b0d3e9a5ddc 100644 --- a/htools/Ganeti/HTools/Program/Hspace.hs +++ b/htools/Ganeti/HTools/Program/Hspace.hs @@ -67,8 +67,6 @@ options = , oStdSpec , oTieredSpec , oSaveCluster - , oShowVer - , oShowHelp ] -- | The allocation phase we're in (initial, after tiered allocs, or diff --git a/htools/hconfd.hs b/htools/hconfd.hs index 32d1208f6161377499e267ba5187fd6df4928de8..dd62f25676a8c317308aa26c1f73ebbe735085e0 100644 --- a/htools/hconfd.hs +++ b/htools/hconfd.hs @@ -33,9 +33,7 @@ import qualified Ganeti.Constants as C -- | Options list and functions. options :: [OptType] options = - [ oShowHelp - , oShowVer - , oNoDaemonize + [ oNoDaemonize , oNoUserChecks , oDebug , oPort C.defaultConfdPort diff --git a/htools/htools.hs b/htools/htools.hs index 2e847d7f2fc97655d349a78dfe950b8d237a200e..08a5a14ff399159363407cf31426d8da6704d1e0 100644 --- a/htools/htools.hs +++ b/htools/htools.hs @@ -35,7 +35,7 @@ import System.IO import System.IO.Error (isDoesNotExistError) import Ganeti.HTools.Utils -import Ganeti.HTools.CLI (parseOpts) +import Ganeti.HTools.CLI (parseOpts, genericOpts) import Ganeti.HTools.Program (personalities) -- | Display usage and exit. @@ -59,5 +59,5 @@ main = do Nothing -> usage name Just (fn, options) -> do cmd_args <- getArgs - (opts, args) <- parseOpts cmd_args name options + (opts, args) <- parseOpts cmd_args name $ options ++ genericOpts fn opts args