]> gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/CLI.py
Added the VerbatimHelpFormatter class to the CLI module.
[dead/census-tools.git] / src / CLI.py
1 from optparse import IndentedHelpFormatter
2 from optparse import OptionParser
3
4 import Configuration.Defaults
5
6
7 def default_option_parser(usage=None):
8 # -h (help) Conflicts with -h HOSTNAME
9 parser = OptionParser(usage=usage, add_help_option = False)
10
11 parser.add_option('-h',
12 '--host',
13 help='The hostname/address where the database is located.',
14 default=Configuration.Defaults.DATABASE_HOST)
15
16 parser.add_option('-d',
17 '--database',
18 help='The database in which the population data are stored.',
19 default=Configuration.Defaults.DATABASE_NAME)
20
21 parser.add_option('-U',
22 '--username',
23 help='The username who has access to the database.',
24 default=Configuration.Defaults.DATABASE_USERNAME)
25
26 return parser
27
28
29
30 class VerbatimHelpFormatter(IndentedHelpFormatter):
31 """
32 The two HelpFormatters supplied with OptParse like to mangle their
33 descriptions during print_help(). This subclassed formatter
34 overrides the format_description() method with an implementation
35 that simply returns the description unmodified.
36 """
37 def format_description(self, description):
38 return description