module Ganeti.DataCollectors.CLI
( Options(..)
, OptType
, defaultOptions
, oShowHelp
, oShowVer
, oShowComp
, oDrbdPairing
, oDrbdStatus
, genericOptions
) where
import System.Console.GetOpt
import Ganeti.BasicTypes
import Ganeti.Common as Common
data Options = Options
{ optShowHelp :: Bool
, optShowComp :: Bool
, optShowVer :: Bool
, optDrbdStatus :: Maybe FilePath
, optDrbdPairing :: Maybe FilePath
} deriving Show
defaultOptions :: Options
defaultOptions = Options
{ optShowHelp = False
, optShowComp = False
, optShowVer = False
, optDrbdStatus = Nothing
, optDrbdPairing = Nothing
}
type OptType = GenericOptType Options
instance StandardOptions Options where
helpRequested = optShowHelp
verRequested = optShowVer
compRequested = optShowComp
requestHelp o = o { optShowHelp = True }
requestVer o = o { optShowVer = True }
requestComp o = o { optShowComp = True }
oDrbdPairing :: OptType
oDrbdPairing =
( Option "p" ["drbd-pairing"]
(ReqArg (\ f o -> Ok o { optDrbdPairing = Just f}) "FILE")
"the FILE containing pairings between instances and DRBD minors",
OptComplFile)
oDrbdStatus :: OptType
oDrbdStatus =
( Option "s" ["drbd-status"]
(ReqArg (\ f o -> Ok o { optDrbdStatus = Just f }) "FILE")
"the DRBD status FILE",
OptComplFile)
genericOptions :: [GenericOptType Options]
genericOptions = [ oShowVer
, oShowHelp
, oShowComp
]