|
24 | 24 | from .exceptions import ClickException |
25 | 25 | from .exceptions import Exit |
26 | 26 | from .exceptions import MissingParameter |
| 27 | +from .exceptions import NoArgsIsHelpError |
27 | 28 | from .exceptions import UsageError |
28 | 29 | from .formatting import HelpFormatter |
29 | 30 | from .formatting import join_options |
@@ -1156,8 +1157,7 @@ def make_context( |
1156 | 1157 |
|
1157 | 1158 | def parse_args(self, ctx: Context, args: list[str]) -> list[str]: |
1158 | 1159 | if not args and self.no_args_is_help and not ctx.resilient_parsing: |
1159 | | - echo(ctx.get_help(), color=ctx.color) |
1160 | | - ctx.exit() |
| 1160 | + raise NoArgsIsHelpError(ctx) |
1161 | 1161 |
|
1162 | 1162 | parser = self.make_parser(ctx) |
1163 | 1163 | opts, args, param_order = parser.parse_args(args=args) |
@@ -1747,8 +1747,7 @@ def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None: |
1747 | 1747 |
|
1748 | 1748 | def parse_args(self, ctx: Context, args: list[str]) -> list[str]: |
1749 | 1749 | if not args and self.no_args_is_help and not ctx.resilient_parsing: |
1750 | | - echo(ctx.get_help(), color=ctx.color) |
1751 | | - ctx.exit() |
| 1750 | + raise NoArgsIsHelpError(ctx) |
1752 | 1751 |
|
1753 | 1752 | rest = super().parse_args(ctx, args) |
1754 | 1753 |
|
@@ -1851,7 +1850,7 @@ def resolve_command( |
1851 | 1850 | # place. |
1852 | 1851 | if cmd is None and not ctx.resilient_parsing: |
1853 | 1852 | if _split_opt(cmd_name)[0]: |
1854 | | - self.parse_args(ctx, ctx.args) |
| 1853 | + self.parse_args(ctx, args) |
1855 | 1854 | ctx.fail(_("No such command {name!r}.").format(name=original_cmd_name)) |
1856 | 1855 | return cmd_name if cmd else None, cmd, args[1:] |
1857 | 1856 |
|
|
0 commit comments