Statistics
| Branch: | Tag: | Revision:

root / htools / Ganeti / DataCollectors / CLI.hs @ ea626b33

History | View | Annotate | Download (2.1 kB)

1 55abd2c7 Iustin Pop
{-| Implementation of DataCollectors CLI functions.
2 55abd2c7 Iustin Pop
3 55abd2c7 Iustin Pop
This module holds the common command-line related functions for the
4 55abd2c7 Iustin Pop
collector binaries.
5 55abd2c7 Iustin Pop
6 55abd2c7 Iustin Pop
-}
7 55abd2c7 Iustin Pop
8 55abd2c7 Iustin Pop
{-
9 55abd2c7 Iustin Pop
10 55abd2c7 Iustin Pop
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
11 55abd2c7 Iustin Pop
12 55abd2c7 Iustin Pop
This program is free software; you can redistribute it and/or modify
13 55abd2c7 Iustin Pop
it under the terms of the GNU General Public License as published by
14 55abd2c7 Iustin Pop
the Free Software Foundation; either version 2 of the License, or
15 55abd2c7 Iustin Pop
(at your option) any later version.
16 55abd2c7 Iustin Pop
17 55abd2c7 Iustin Pop
This program is distributed in the hope that it will be useful, but
18 55abd2c7 Iustin Pop
WITHOUT ANY WARRANTY; without even the implied warranty of
19 55abd2c7 Iustin Pop
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 55abd2c7 Iustin Pop
General Public License for more details.
21 55abd2c7 Iustin Pop
22 55abd2c7 Iustin Pop
You should have received a copy of the GNU General Public License
23 55abd2c7 Iustin Pop
along with this program; if not, write to the Free Software
24 55abd2c7 Iustin Pop
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 55abd2c7 Iustin Pop
02110-1301, USA.
26 55abd2c7 Iustin Pop
27 55abd2c7 Iustin Pop
-}
28 55abd2c7 Iustin Pop
29 55abd2c7 Iustin Pop
module Ganeti.DataCollectors.CLI
30 55abd2c7 Iustin Pop
  ( Options(..)
31 55abd2c7 Iustin Pop
  , OptType
32 55abd2c7 Iustin Pop
  , defaultOptions
33 55abd2c7 Iustin Pop
  -- * The options
34 55abd2c7 Iustin Pop
  , oShowHelp
35 55abd2c7 Iustin Pop
  , oShowVer
36 55abd2c7 Iustin Pop
  , oShowComp
37 55abd2c7 Iustin Pop
  , genericOptions
38 55abd2c7 Iustin Pop
  ) where
39 55abd2c7 Iustin Pop
40 55abd2c7 Iustin Pop
import Ganeti.Common as Common
41 55abd2c7 Iustin Pop
42 55abd2c7 Iustin Pop
-- * Data types
43 55abd2c7 Iustin Pop
44 55abd2c7 Iustin Pop
-- | Command line options structure.
45 55abd2c7 Iustin Pop
data Options = Options
46 55abd2c7 Iustin Pop
  { optShowHelp    :: Bool           -- ^ Just show the help
47 55abd2c7 Iustin Pop
  , optShowComp    :: Bool           -- ^ Just show the completion info
48 55abd2c7 Iustin Pop
  , optShowVer     :: Bool           -- ^ Just show the program version
49 55abd2c7 Iustin Pop
  } deriving Show
50 55abd2c7 Iustin Pop
51 55abd2c7 Iustin Pop
-- | Default values for the command line options.
52 55abd2c7 Iustin Pop
defaultOptions :: Options
53 55abd2c7 Iustin Pop
defaultOptions  = Options
54 55abd2c7 Iustin Pop
  { optShowHelp    = False
55 55abd2c7 Iustin Pop
  , optShowComp    = False
56 55abd2c7 Iustin Pop
  , optShowVer     = False
57 55abd2c7 Iustin Pop
  }
58 55abd2c7 Iustin Pop
59 55abd2c7 Iustin Pop
-- | Abbreviation for the option type.
60 55abd2c7 Iustin Pop
type OptType = GenericOptType Options
61 55abd2c7 Iustin Pop
62 55abd2c7 Iustin Pop
instance StandardOptions Options where
63 55abd2c7 Iustin Pop
  helpRequested = optShowHelp
64 55abd2c7 Iustin Pop
  verRequested  = optShowVer
65 55abd2c7 Iustin Pop
  compRequested = optShowComp
66 55abd2c7 Iustin Pop
  requestHelp o = o { optShowHelp = True }
67 55abd2c7 Iustin Pop
  requestVer  o = o { optShowVer  = True }
68 55abd2c7 Iustin Pop
  requestComp o = o { optShowComp = True }
69 55abd2c7 Iustin Pop
70 55abd2c7 Iustin Pop
-- * Command line options
71 55abd2c7 Iustin Pop
72 55abd2c7 Iustin Pop
-- | Generic options.
73 55abd2c7 Iustin Pop
genericOptions :: [GenericOptType Options]
74 55abd2c7 Iustin Pop
genericOptions =  [ oShowVer
75 55abd2c7 Iustin Pop
                  , oShowHelp
76 55abd2c7 Iustin Pop
                  , oShowComp
77 55abd2c7 Iustin Pop
                  ]