Revision 55abd2c7

b/Makefile.am
455 455
	htools/Ganeti/Confd/Utils.hs \
456 456
	htools/Ganeti/Config.hs \
457 457
	htools/Ganeti/Daemon.hs \
458
	htools/Ganeti/DataCollectors/CLI.hs \
458 459
	htools/Ganeti/DataCollectors/Drbd.hs \
459 460
	htools/Ganeti/DataCollectors/Program.hs \
460 461
	htools/Ganeti/Errors.hs \
b/htools/Ganeti/DataCollectors/CLI.hs
1
{-| Implementation of DataCollectors CLI functions.
2

  
3
This module holds the common command-line related functions for the
4
collector binaries.
5

  
6
-}
7

  
8
{-
9

  
10
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
11

  
12
This program is free software; you can redistribute it and/or modify
13
it under the terms of the GNU General Public License as published by
14
the Free Software Foundation; either version 2 of the License, or
15
(at your option) any later version.
16

  
17
This program is distributed in the hope that it will be useful, but
18
WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
General Public License for more details.
21

  
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
02110-1301, USA.
26

  
27
-}
28

  
29
module Ganeti.DataCollectors.CLI
30
  ( Options(..)
31
  , OptType
32
  , defaultOptions
33
  -- * The options
34
  , oShowHelp
35
  , oShowVer
36
  , oShowComp
37
  , genericOptions
38
  ) where
39

  
40
import Ganeti.Common as Common
41

  
42
-- * Data types
43

  
44
-- | Command line options structure.
45
data Options = Options
46
  { optShowHelp    :: Bool           -- ^ Just show the help
47
  , optShowComp    :: Bool           -- ^ Just show the completion info
48
  , optShowVer     :: Bool           -- ^ Just show the program version
49
  } deriving Show
50

  
51
-- | Default values for the command line options.
52
defaultOptions :: Options
53
defaultOptions  = Options
54
  { optShowHelp    = False
55
  , optShowComp    = False
56
  , optShowVer     = False
57
  }
58

  
59
-- | Abbreviation for the option type.
60
type OptType = GenericOptType Options
61

  
62
instance StandardOptions Options where
63
  helpRequested = optShowHelp
64
  verRequested  = optShowVer
65
  compRequested = optShowComp
66
  requestHelp o = o { optShowHelp = True }
67
  requestVer  o = o { optShowVer  = True }
68
  requestComp o = o { optShowComp = True }
69

  
70
-- * Command line options
71

  
72
-- | Generic options.
73
genericOptions :: [GenericOptType Options]
74
genericOptions =  [ oShowVer
75
                  , oShowHelp
76
                  , oShowComp
77
                  ]
b/htools/Ganeti/DataCollectors/Drbd.hs
39 39
import qualified Ganeti.Constants as C
40 40
import Ganeti.Block.Drbd.Parser(drbdStatusParser)
41 41
import Ganeti.Common
42
import Ganeti.HTools.CLI
42
import Ganeti.DataCollectors.CLI
43 43
import Ganeti.Utils
44 44

  
45 45

  
b/htools/Ganeti/DataCollectors/Program.hs
26 26
module Ganeti.DataCollectors.Program (personalities) where
27 27

  
28 28
import Ganeti.Common (ArgCompletion)
29
import Ganeti.HTools.CLI (OptType, Options)
29
import Ganeti.DataCollectors.CLI (OptType, Options)
30 30

  
31 31
import qualified Ganeti.DataCollectors.Drbd as Drbd
32 32

  
b/htools/Ganeti/HTools/CLI.hs
189 189
  , optVerbose     = 1
190 190
  }
191 191

  
192
-- | Abrreviation for the option type.
192
-- | Abbreviation for the option type.
193 193
type OptType = GenericOptType Options
194 194

  
195 195
instance StandardOptions Options where
b/htools/mon-collector.hs
29 29
import System.Environment
30 30
import System.IO
31 31

  
32
import Ganeti.Common
32 33
import Ganeti.Utils
33
import Ganeti.HTools.CLI (parseOpts, genericOpts)
34
import Ganeti.DataCollectors.CLI (genericOptions, defaultOptions)
34 35
import Ganeti.DataCollectors.Program (personalities)
35 36

  
36 37
-- | Display usage and exit.
......
56 57
    Just (fn, options, arguments) -> do
57 58
         let actual_args = tail cmd_args
58 59
         real_options <- options
59
         (opts, args) <- parseOpts actual_args name (real_options ++
60
                           genericOpts) arguments
60
         (opts, args) <- parseOpts defaultOptions actual_args name
61
                           (real_options ++ genericOptions) arguments
61 62
         fn opts args

Also available in: Unified diff