Extra format methods for multi methods that adds all the commands after the options.
(self, ctx: Context, formatter: HelpFormatter)
| 1892 | self.format_commands(ctx, formatter) |
| 1893 | |
| 1894 | def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None: |
| 1895 | """Extra format methods for multi methods that adds all the commands |
| 1896 | after the options. |
| 1897 | """ |
| 1898 | commands = [] |
| 1899 | for subcommand in self.list_commands(ctx): |
| 1900 | cmd = self.get_command(ctx, subcommand) |
| 1901 | # What is this, the tool lied about a command. Ignore it |
| 1902 | if cmd is None: |
| 1903 | continue |
| 1904 | if cmd.hidden: |
| 1905 | continue |
| 1906 | |
| 1907 | commands.append((subcommand, cmd)) |
| 1908 | |
| 1909 | # allow for 3 times the default spacing |
| 1910 | if len(commands): |
| 1911 | limit = formatter.width - 6 - max(len(cmd[0]) for cmd in commands) |
| 1912 | |
| 1913 | rows = [] |
| 1914 | for subcommand, cmd in commands: |
| 1915 | help = cmd.get_short_help_str(limit) |
| 1916 | rows.append((subcommand, help)) |
| 1917 | |
| 1918 | if rows: |
| 1919 | with formatter.section(_("Commands")): |
| 1920 | formatter.write_dl(rows) |
| 1921 | |
| 1922 | def parse_args(self, ctx: Context, args: list[str]) -> list[str]: |
| 1923 | if not args and self.no_args_is_help and not ctx.resilient_parsing: |
no test coverage detected