Initial upload: Git AI Documentation Generator v0.1.0
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
123
src/output.py
Normal file
123
src/output.py
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
"""Output formatting module using Rich."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.panel import Panel
|
||||||
|
from rich.theme import Theme
|
||||||
|
|
||||||
|
error_theme = Theme({
|
||||||
|
"error": "red bold",
|
||||||
|
"warning": "yellow bold",
|
||||||
|
"success": "green",
|
||||||
|
"info": "cyan",
|
||||||
|
})
|
||||||
|
|
||||||
|
console = Console(force_terminal=True)
|
||||||
|
error_console = Console(theme=error_theme, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
def display_commit_message(message: str, model: str = "llama3.2") -> None:
|
||||||
|
"""Display a generated commit message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message: The commit message to display.
|
||||||
|
model: The model used to generate it.
|
||||||
|
"""
|
||||||
|
console.print(Panel(f"[bold]Generated Commit Message[/bold]\n\n{message}", title=f"Model: {model}"))
|
||||||
|
|
||||||
|
|
||||||
|
def display_changelog(changelog: str, from_version: str | None, to_version: str | None) -> None:
|
||||||
|
"""Display a generated changelog.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
changelog: The changelog content.
|
||||||
|
from_version: Starting version.
|
||||||
|
to_version: Ending version.
|
||||||
|
"""
|
||||||
|
title = "Generated Changelog"
|
||||||
|
if from_version and to_version:
|
||||||
|
title = f"Changelog: {from_version} -> {to_version}"
|
||||||
|
elif from_version:
|
||||||
|
title = f"Changelog: {from_version} -> current"
|
||||||
|
console.print(Panel(changelog, title=title, expand=False))
|
||||||
|
|
||||||
|
|
||||||
|
def display_api_docs(docs: str, framework: str | None = None) -> None:
|
||||||
|
"""Display generated API documentation.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
docs: The documentation content.
|
||||||
|
framework: The detected framework.
|
||||||
|
"""
|
||||||
|
title = "Generated API Documentation"
|
||||||
|
if framework:
|
||||||
|
title += f" ({framework})"
|
||||||
|
console.print(Panel(docs, title=title, expand=False))
|
||||||
|
|
||||||
|
|
||||||
|
def display_error(message: str) -> None:
|
||||||
|
"""Display an error message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message: The error message.
|
||||||
|
"""
|
||||||
|
error_console.print(f"[red]Error:[/red] {message}")
|
||||||
|
|
||||||
|
|
||||||
|
def display_warning(message: str) -> None:
|
||||||
|
"""Display a warning message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message: The warning message.
|
||||||
|
"""
|
||||||
|
console.print(f"[yellow]Warning:[/yellow] {message}")
|
||||||
|
|
||||||
|
|
||||||
|
def display_success(message: str) -> None:
|
||||||
|
"""Display a success message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message: The success message.
|
||||||
|
"""
|
||||||
|
console.print(f"[green]Success:[/green] {message}")
|
||||||
|
|
||||||
|
|
||||||
|
def display_info(message: str) -> None:
|
||||||
|
"""Display an info message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message: The info message.
|
||||||
|
"""
|
||||||
|
console.print(f"[cyan]Info:[/cyan] {message}")
|
||||||
|
|
||||||
|
|
||||||
|
def display_diff(diff_content: str, file_path: str) -> None:
|
||||||
|
"""Display a diff with syntax highlighting.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
diff_content: The diff content.
|
||||||
|
file_path: The file path.
|
||||||
|
"""
|
||||||
|
console.print(f"\n[bold]Changes in {file_path}[/bold]")
|
||||||
|
console.print(diff_content)
|
||||||
|
|
||||||
|
|
||||||
|
def display_loading(message: str) -> None:
|
||||||
|
"""Display a loading message with spinner.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message: The loading message.
|
||||||
|
"""
|
||||||
|
console.status(message)
|
||||||
|
|
||||||
|
|
||||||
|
def display_model_info(host: str, model: str) -> None:
|
||||||
|
"""Display Ollama connection info.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
host: Ollama host URL.
|
||||||
|
model: Model name.
|
||||||
|
"""
|
||||||
|
console.print(f"[cyan]Connected to Ollama at {host}[/cyan]")
|
||||||
|
console.print(f"[cyan]Using model: {model}[/cyan]")
|
||||||
Reference in New Issue
Block a user