Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better formatting to warnings #264

Merged
merged 8 commits into from
Dec 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor warning display with Rich formatting.
Replace plain click-based warnings with styled Rich panels for better visibility. This enhances user experience by providing clearer and more visually organized warnings.
  • Loading branch information
coordt committed Dec 14, 2024
commit 2b7c905c792e1cbe22040a5ba890c4440990f99b
19 changes: 18 additions & 1 deletion bumpversion/ui.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"""Utilities for user interface."""

import logging
import sys

import click
from click import UsageError, secho
from rich.logging import RichHandler
from rich.padding import Padding
from rich.panel import Panel
from rich_click.rich_help_formatter import RichHelpFormatter

from bumpversion.indented_logger import IndentedLoggerAdapter

@@ -50,4 +54,17 @@ def print_error(msg: str) -> None:

def print_warning(msg: str) -> None:
"""Echo a warning to the console."""
secho(f"\nWARNING:\n\n{msg}\n", fg="yellow")
formatter = RichHelpFormatter(file=sys.stderr)
config = formatter.config

formatter.write(
Padding(
Panel(
formatter.highlighter(msg),
border_style="yellow",
title="Warning",
title_align=config.align_errors_panel,
),
(0, 0, 1, 0),
)
)