cloup._sections¶
Classes summary¶
|
A group of (sub)commands to show in the same help section of a |
|
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.6.0: Removed the deprecated old name
GroupSection.Changed in version 0.5.0: Introduced the new name
Sectionand deprecated the oldGroupSection.- 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.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
Sectionobjects to the constructor setting the argumentsectionsusing
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
Sectionto 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
sectionis 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=Trueand 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]¶