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 24, 2024
1 parent 6c31320 commit dae982c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rich_click/rich_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ def main(
if not standalone_mode:
raise
if ctx is not None:
config = ctx.help_config
formatter = ctx.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(config=config, file=sys.stderr)
from rich_click.rich_help_rendering import rich_format_error

rich_format_error(e, formatter)
Expand All @@ -192,10 +192,10 @@ def main(
raise
try:
if ctx is not None:
config = ctx.help_config
formatter = ctx.formatter
else:
config = self._generate_rich_help_config()
formatter = self.context_class.formatter_class(config=config)
formatter = self.context_class.formatter_class(config=config)
except Exception:
click.echo("Aborted!", file=sys.stderr)
else:
Expand Down
2 changes: 2 additions & 0 deletions src/rich_click/rich_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def __init__(
else:
self.help_config = rich_help_config

self.formatter = self.make_formatter()

def make_formatter(self) -> RichHelpFormatter:
"""Create the Rich Help Formatter."""
formatter = self.formatter_class(
Expand Down

0 comments on commit dae982c

Please sign in to comment.