Skip to content

Commit a8c7ff9

Browse files
committed
python: support raw description formatter with help_formatter()
Problem: There is currently no way to get raw description and epilog formatting with the FluxHelpFormatter class returned from help_formatter(). Add a FluxRawDescriptionHelpFormatter class that inherits from both FluxHelpFormatter and RawDescriptionHelpFormatter for this purpose. Return this class instead of FluxHelpFormatter if a new optional raw_description parameter is set in the call to help_formatter().
1 parent d78b3d9 commit a8c7ff9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/bindings/python/flux/util.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def encode_topic(topic):
123123
return topic
124124

125125

126-
def help_formatter(argwidth=40):
126+
def help_formatter(argwidth=40, raw_description=False):
127127
"""
128128
Return our 'clean' HelpFormatter, if possible, with a wider default
129129
for the max width allowed for options.
@@ -162,6 +162,16 @@ def _format_action_invocation(self, action):
162162
args_string = self._format_args(action, default)
163163
return optstring + "=" + args_string
164164

165+
class FluxRawDescriptionHelpFormatter(
166+
FluxHelpFormatter, argparse.RawDescriptionHelpFormatter
167+
):
168+
pass
169+
170+
if raw_description:
171+
return lambda prog: FluxRawDescriptionHelpFormatter(
172+
prog, max_help_position=argwidth
173+
)
174+
165175
return lambda prog: FluxHelpFormatter(prog, max_help_position=argwidth)
166176

167177

0 commit comments

Comments
 (0)