Revision 2e6ef129
b/htools/Ganeti/Common.hs | ||
---|---|---|
31 | 31 |
, StandardOptions(..) |
32 | 32 |
, OptCompletion(..) |
33 | 33 |
, ArgCompletion(..) |
34 |
, PersonalityList |
|
34 | 35 |
, optComplYesNo |
35 | 36 |
, oShowHelp |
36 | 37 |
, oShowVer |
... | ... | |
86 | 87 |
data ArgCompletion = ArgCompletion OptCompletion Int (Maybe Int) |
87 | 88 |
deriving (Show, Eq) |
88 | 89 |
|
90 |
-- | A personality definition. |
|
91 |
type Personality a = ( a -> [String] -> IO () -- The main function |
|
92 |
, IO [GenericOptType a] -- The options |
|
93 |
, [ArgCompletion] -- The description of args |
|
94 |
) |
|
95 |
|
|
96 |
-- | Personality lists type, common across all binaries that expose |
|
97 |
-- multiple personalities. |
|
98 |
type PersonalityList a = [(String, Personality a)] |
|
99 |
|
|
89 | 100 |
-- | Yes\/no choices completion. |
90 | 101 |
optComplYesNo :: OptCompletion |
91 | 102 |
optComplYesNo = OptComplChoices ["yes", "no"] |
b/htools/Ganeti/DataCollectors/Program.hs | ||
---|---|---|
25 | 25 |
|
26 | 26 |
module Ganeti.DataCollectors.Program (personalities) where |
27 | 27 |
|
28 |
import Ganeti.Common (ArgCompletion)
|
|
29 |
import Ganeti.DataCollectors.CLI (OptType, Options)
|
|
28 |
import Ganeti.Common (PersonalityList)
|
|
29 |
import Ganeti.DataCollectors.CLI (Options) |
|
30 | 30 |
|
31 | 31 |
import qualified Ganeti.DataCollectors.Drbd as Drbd |
32 | 32 |
|
33 | 33 |
-- | Supported binaries. |
34 |
personalities :: [(String, |
|
35 |
(Options -> [String] -> IO (), IO [OptType], |
|
36 |
[ArgCompletion]))] |
|
34 |
personalities :: PersonalityList Options |
|
37 | 35 |
personalities = [ ("drbd", (Drbd.main, Drbd.options, Drbd.arguments)) |
38 | 36 |
] |
b/htools/Ganeti/HTools/Program.hs | ||
---|---|---|
27 | 27 |
( personalities |
28 | 28 |
) where |
29 | 29 |
|
30 |
import Ganeti.Common (ArgCompletion)
|
|
31 |
import Ganeti.HTools.CLI (OptType, Options)
|
|
30 |
import Ganeti.Common (PersonalityList)
|
|
31 |
import Ganeti.HTools.CLI (Options) |
|
32 | 32 |
|
33 | 33 |
import qualified Ganeti.HTools.Program.Hail as Hail |
34 | 34 |
import qualified Ganeti.HTools.Program.Hbal as Hbal |
... | ... | |
38 | 38 |
import qualified Ganeti.HTools.Program.Hinfo as Hinfo |
39 | 39 |
|
40 | 40 |
-- | Supported binaries. |
41 |
personalities :: [(String, |
|
42 |
(Options -> [String] -> IO (), IO [OptType], |
|
43 |
[ArgCompletion]))] |
|
41 |
personalities :: PersonalityList Options |
|
44 | 42 |
personalities = [ ("hail", (Hail.main, Hail.options, Hail.arguments)) |
45 | 43 |
, ("hbal", (Hbal.main, Hbal.options, Hbal.arguments)) |
46 | 44 |
, ("hcheck", (Hcheck.main, Hcheck.options, Hcheck.arguments)) |
Also available in: Unified diff