def format_option(self, option): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = [] |
opts = self.option_strings[option] |
opt_width = self.help_position - self.current_indent - 2 |
if len(opts) > opt_width: |
opts = "%*s%s\n" % (self.current_indent, "", opts) |
indent_first = self.help_position |
else: |
opts = "%*s%-*s " % (self.current_indent, "", opt_width, opts) |
indent_first = 0 |
result.append(opts) |
if option.help: |
help_text = self.expand_default(option) |
help_lines = textwrap.wrap(help_text, self.help_width) |
result.append("%*s%s\n" % (indent_first, "", help_lines[0])) |
result.extend(["%*s%s\n" % (self.help_position, "", line) |
for line in help_lines[1:]]) |
elif opts[-1] != "\n": |
result.append("\n") |
return "".join(result) |