Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / DataCollectors / CLI.hs @ 3add7574

History | View | Annotate | Download (2.1 kB)

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
                  ]