aboutsummaryrefslogtreecommitdiff
path: root/lib/dodai/config/option.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dodai/config/option.py')
-rw-r--r--lib/dodai/config/option.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/dodai/config/option.py b/lib/dodai/config/option.py
new file mode 100644
index 0000000..0561881
--- /dev/null
+++ b/lib/dodai/config/option.py
@@ -0,0 +1,61 @@
1# Copyright (C) 2010 Leonard Thomas
2#
3# This file is part of Dodai.
4#
5# Dodai is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# Dodai is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with Dodai. If not, see <http://www.gnu.org/licenses/>.
17
18
19from optparse import OptionParser
20
21class ConfigOption(object):
22
23 def __init__(self):
24
25 self.parser = OptionParser()
26 self._options = None
27 self._args = []
28
29 def get_args(self):
30 self._parse_args()
31 return self._args
32
33 def get_options(self):
34 self._parse_args()
35 return self._options
36
37 def _parse_args(self):
38 options, args = self.parser.parse_args()
39 self._options = options
40 self._args = args
41
42 def add_quiet(self):
43
44 self.parser.add_option("-q", "--quiet", dest="verbose", default=True,
45 action="store_false",
46 help="Don't print status messages to the screen")
47
48 def add_verbose(self):
49 self.parser.add_option("-v", "--verbose", dest="verbose",
50 action="store_true",
51 default=False, help="Print status messages to the screen")
52
53 def add_log_level(self, default='critical'):
54 self.parser.add_option("-l", "--log-level", dest="log_level",
55 default=default, help="Sets the log level")
56
57 def add_setup(self):
58 self.parser.add_option('', "--setup", dest="setup",
59 action="store_true", default=False,
60 help="run the setup which builds the config "\
61 "files.")