cloup._sections
¶
Classes summary¶
|
A group of (sub)commands to show in the same help section of a |
|
Old name of Section when the implementation of the feature was hard-coded and tightly coupled to |
|
Adds to a click.MultiCommand the possibility to organize its subcommands in multiple help sections. |
Contents¶
-
cloup._sections.
CommandType
¶
-
cloup._sections.
Subcommands
¶
-
class
cloup._sections.
Section
(title: str, commands: Subcommands = (), sorted: bool = False)[source]¶ A group of (sub)commands to show in the same help section of a
MultiCommand
. You can use sections with any Command that inherits fromSectionMixin
.Changed in version 0.5.0: This class was renamed from
GroupSection
(deprecated) toSection
.- Parameters
-
classmethod
sorted
(cls, title: str, commands: Subcommands = ()) → cloup._sections.Section[source]¶
-
add_command
(self, cmd: click.Command, name: Optional[str] = None)[source]¶
-
list_commands
(self) → List[Tuple[str, click.Command]][source]¶
-
class
cloup._sections.
GroupSection
(*args, **kwargs)[source]¶ Bases:
cloup._sections.Section
Old name of Section when the implementation of the feature was hard-coded and tightly coupled to
cloup.Group
.Deprecated since version 0.5.0: To be removed in v0.6.0. Use
Section
instead.
-
class
cloup._sections.
SectionMixin
(*args, commands: Optional[Dict[str, click.Command]] = None, sections: Iterable[Section] = (), align_sections: bool = True, **kwargs)[source]¶ Adds to a click.MultiCommand the possibility to organize its subcommands in multiple help sections.
Sections can be specified in the following ways:
passing a list of
Section
objects to the constructor setting the argumentsections
using
add_section()
to add a single sectionusing
add_command()
with the argument section set
Commands not assigned to any user-defined section are added to the “default section”, whose title is “Commands” or “Other commands” depending on whether it is the only section or not. The default section is the last shown section in the help and its commands are listed in lexicographic order.
New in version 0.5.0.
- Parameters
commands (Optional[Dict[str, click.core.Command]]) –
sections (Iterable[cloup._sections.Section]) –
align_sections (bool) –
-
add_section
(self, section: cloup._sections.Section)[source]¶ Adds a
Section
to this group. You can add the same section object a single time.
-
section
(self, title: str, *commands: click.Command, **attrs) → cloup._sections.Section[source]¶ Creates a new
Section
, adds it to this group and returns it.
-
add_command
(self, cmd: click.Command, name: Optional[str] = None, section: Optional[Section] = None)[source]¶ Adds a new command. If
section
is None, the command is added to the default section.
-
list_sections
(self, ctx: click.Context, include_default_section: bool = True) → List[Section][source]¶ Returns the list of all sections in the “correct order”. if
include_default_section=True
and the default section is non-empty, it will be included at the end of the list.
-
format_commands
(self, ctx: click.Context, formatter: click.HelpFormatter)[source]¶
-
format_section
(self, ctx: click.Context, formatter: click.HelpFormatter, section: cloup._sections.Section, command_col_width: Optional[int] = None)[source]¶