projects
/
hooke.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
07189ad
)
Flesh out command line help messages.
author
W. Trevor King
<wking@drexel.edu>
Sun, 29 Aug 2010 00:47:43 +0000
(20:47 -0400)
committer
W. Trevor King
<wking@drexel.edu>
Sun, 29 Aug 2010 00:47:43 +0000
(20:47 -0400)
hooke/ui/commandline.py
patch
|
blob
|
history
diff --git
a/hooke/ui/commandline.py
b/hooke/ui/commandline.py
index efed63488b553f66856ee82c9f42e334c72b868e..be0f14a8b02184dc4ecf1551587a152d09a0605a 100644
(file)
--- a/
hooke/ui/commandline.py
+++ b/
hooke/ui/commandline.py
@@
-74,7
+74,8
@@
class CommandLineParser (optparse.OptionParser):
try:
self.add_option(
'--disable-%s' % name, dest=name,
try:
self.add_option(
'--disable-%s' % name, dest=name,
- default=Default, action='store_false')
+ default=Default, action='store_false',
+ help=self._argument_help(a))
except optparse.OptionConflictError, e:
logging.warn('error in %s: %s' % (command, e))
raise
except optparse.OptionConflictError, e:
logging.warn('error in %s: %s' % (command, e))
raise
@@
-84,7
+85,8
@@
class CommandLineParser (optparse.OptionParser):
try:
self.add_option(
'--enable-%s' % name, dest=name,
try:
self.add_option(
'--enable-%s' % name, dest=name,
- default=Default, action='store_true')
+ default=Default, action='store_true',
+ help=self._argument_help(a))
except optparse.OptionConflictError, e:
logging.warn('error in %s: %s' % (command, e))
raise
except optparse.OptionConflictError, e:
logging.warn('error in %s: %s' % (command, e))
raise
@@
-97,7
+99,8
@@
class CommandLineParser (optparse.OptionParser):
type = 'string'
try:
self.add_option(
type = 'string'
try:
self.add_option(
- '--%s' % name, dest=name, type=type, default=Default)
+ '--%s' % name, dest=name, type=type, default=Default,
+ help=self._argument_help(a))
except optparse.OptionConflictError, e:
logging.warn('error in %s: %s' % (command, e))
raise
except optparse.OptionConflictError, e:
logging.warn('error in %s: %s' % (command, e))
raise
@@
-113,6
+116,10
@@
class CommandLineParser (optparse.OptionParser):
self.command_args.remove(infinite_counter)
self.command_args.append(infinite_counter)
self.command_args.remove(infinite_counter)
self.command_args.append(infinite_counter)
+ def _argument_help(self, argument):
+ return '%s (%s)' % (argument._help, argument.default)
+ # default in the case of callbacks, config-backed values, etc.?
+
def exit(self, status=0, msg=None):
"""Override :meth:`optparse.OptionParser.exit` which calls
:func:`sys.exit`.
def exit(self, status=0, msg=None):
"""Override :meth:`optparse.OptionParser.exit` which calls
:func:`sys.exit`.
@@
-336,14
+343,15
@@
class HelpCommand (CommandMethod):
self.parser = CommandLineParser(self.command, self.name_fn)
def __call__(self):
self.parser = CommandLineParser(self.command, self.name_fn)
def __call__(self):
- blocks = [self.command.help(name_fn=self.name_fn),
+ blocks = [self.parser.format_help(),
+ self._command_message(),
'----',
'Usage: ' + self._usage_string(),
'']
self.cmd.stdout.write('\n'.join(blocks))
'----',
'Usage: ' + self._usage_string(),
'']
self.cmd.stdout.write('\n'.join(blocks))
- def _message(self):
- return self.command.
help(name_fn=self.name_fn)
+ def _
command_
message(self):
+ return self.command.
_help
def _usage_string(self):
if len(self.parser.command_opts) == 0:
def _usage_string(self):
if len(self.parser.command_opts) == 0: