Skip to content
Snippets Groups Projects
Commit 2e6ef129 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a type alias for the personality lists


The signature of the personality definitions is so ugly that, at
least, we should hide it a bit behind a type alias.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 55abd2c7
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ module Ganeti.Common
, StandardOptions(..)
, OptCompletion(..)
, ArgCompletion(..)
, PersonalityList
, optComplYesNo
, oShowHelp
, oShowVer
......@@ -86,6 +87,16 @@ data OptCompletion = OptComplNone -- ^ No parameter to this option
data ArgCompletion = ArgCompletion OptCompletion Int (Maybe Int)
deriving (Show, Eq)
-- | A personality definition.
type Personality a = ( a -> [String] -> IO () -- The main function
, IO [GenericOptType a] -- The options
, [ArgCompletion] -- The description of args
)
-- | Personality lists type, common across all binaries that expose
-- multiple personalities.
type PersonalityList a = [(String, Personality a)]
-- | Yes\/no choices completion.
optComplYesNo :: OptCompletion
optComplYesNo = OptComplChoices ["yes", "no"]
......
......@@ -25,14 +25,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Ganeti.DataCollectors.Program (personalities) where
import Ganeti.Common (ArgCompletion)
import Ganeti.DataCollectors.CLI (OptType, Options)
import Ganeti.Common (PersonalityList)
import Ganeti.DataCollectors.CLI (Options)
import qualified Ganeti.DataCollectors.Drbd as Drbd
-- | Supported binaries.
personalities :: [(String,
(Options -> [String] -> IO (), IO [OptType],
[ArgCompletion]))]
personalities :: PersonalityList Options
personalities = [ ("drbd", (Drbd.main, Drbd.options, Drbd.arguments))
]
......@@ -27,8 +27,8 @@ module Ganeti.HTools.Program
( personalities
) where
import Ganeti.Common (ArgCompletion)
import Ganeti.HTools.CLI (OptType, Options)
import Ganeti.Common (PersonalityList)
import Ganeti.HTools.CLI (Options)
import qualified Ganeti.HTools.Program.Hail as Hail
import qualified Ganeti.HTools.Program.Hbal as Hbal
......@@ -38,9 +38,7 @@ import qualified Ganeti.HTools.Program.Hspace as Hspace
import qualified Ganeti.HTools.Program.Hinfo as Hinfo
-- | Supported binaries.
personalities :: [(String,
(Options -> [String] -> IO (), IO [OptType],
[ArgCompletion]))]
personalities :: PersonalityList Options
personalities = [ ("hail", (Hail.main, Hail.options, Hail.arguments))
, ("hbal", (Hbal.main, Hbal.options, Hbal.arguments))
, ("hcheck", (Hcheck.main, Hcheck.options, Hcheck.arguments))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment