Skip to content

Commit

Permalink
fix/exception-in-console
Browse files Browse the repository at this point in the history
  • Loading branch information
sankarngrjn committed Nov 29, 2024
1 parent 6c31320 commit c7e8b8e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/rich_click/rich_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,14 @@ def main(
if not standalone_mode:
raise
if ctx is not None:
config = ctx.help_config
formatter = ctx.make_formatter()
else:
config = self._generate_rich_help_config()
formatter = self.context_class.formatter_class(config=config, file=sys.stderr)
formatter = self.context_class.formatter_class(
console=self.console,
config=config,
file=sys.stderr
)
from rich_click.rich_help_rendering import rich_format_error

rich_format_error(e, formatter)
Expand All @@ -192,10 +196,10 @@ def main(
raise
try:
if ctx is not None:
config = ctx.help_config
formatter = ctx.make_formatter()
else:
config = self._generate_rich_help_config()
formatter = self.context_class.formatter_class(config=config)
formatter = self.context_class.formatter_class(console=self.console, config=config)
except Exception:
click.echo("Aborted!", file=sys.stderr)
else:
Expand Down

0 comments on commit c7e8b8e

Please sign in to comment.