You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cloup relies on a hack (padding) to align multiple sections because click.HelpFormatter doesn't support it.
Click 7 adds an extra empty line only after options with a long description taking multiple lines. This makes vertical spacing inconsistent, especially when using Cloup. This behaviour was removed in Click 8 on my request.
Customizing the help is unnecessarily difficult in Click, especially in Click 7. There's work in progress but the new formatting system won't be released in Click 8.0.
The formatting code (especially HelpFormatter.write_dl) has several issues and there's no point in fixing them in Click since they are going to redesign the entire formatting system.
Requirements
Should support alignment of multiple sections; this can be implemented (at the core) by adding col1_width=None arguments to write_dl
Should have more attributes for customization, like col1_max_width (called col_max in write_dl), col_spacing.
Optionally, implements a row_sep attribute that is written after each row of a definition list; this allows clients to separate rows with an empty line, for example.
If there's not enough space for a 2nd column (min 15-20 chars), write a definition list as a linear list with the option.help printed always under the opts, indented.
Improve help readability when the available width for the second column is small.
I decided to stay compatible with Click by subclassing HelpFormatter for now. To allow styling of stuff like option metavar, default values and envvars, I'd need to subclass Option and move even more formatting logic to the formatter so that it can deal with options and commands directly (rather than with generic "rows" and "sections"). Let's keep it simple for now.
Motivations
Cloup relies on a hack (padding) to align multiple sections because
click.HelpFormatter
doesn't support it.Click 7 adds an extra empty line only after options with a long description taking multiple lines. This makes vertical spacing inconsistent, especially when using Cloup. This behaviour was removed in Click 8 on my request.
Customizing the help is unnecessarily difficult in Click, especially in Click 7. There's work in progress but the new formatting system won't be released in Click 8.0.
The formatting code (especially
HelpFormatter.write_dl
) has several issues and there's no point in fixing them in Click since they are going to redesign the entire formatting system.Requirements
col1_width=None
arguments towrite_dl
col1_max_width
(calledcol_max
inwrite_dl
),col_spacing
.row_sep
attribute that is written after each row of a definition list; this allows clients to separate rows with an empty line, for example.option.help
printed always under theopts
, indented.Changes to support the feature
Using a custom help formatter will require other structural changes:
Context
and addalign_option_groups
andalign_sections
attrs #15) implement of a customContext
that uses the customHelpFormatter
; add aBaseCommand(click.Command)
that uses the customContext
and make it the parent class ofCommand
andMultiCommand
.OptionGroupMixin
andSectionMixin
use the custom formatterformatter_settings
to bothContext
andBaseCommand
to support easy customization.The text was updated successfully, but these errors were encountered: