Skip to content

Commit

Permalink
✨ feat: update README and clean up code formatting
Browse files Browse the repository at this point in the history
✨ feat: update README and clean up code formatting

📄 Documentation:
- Updated the README to reflect the new author @Arakiss.
- Improved documentation clarity and formatting.

🔧 Code Improvement:
- Consistent use of double quotes for string literals.
- Formatted import statements for better readability.
- Added new lines for better code separation in several functions.

These changes enhance documentation accuracy and improve code readability and consistency.
  • Loading branch information
Arakiss committed Dec 6, 2024
1 parent 50e795b commit a8d5b8a
Show file tree
Hide file tree
Showing 9 changed files with 278 additions and 238 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file

---

<p align="center">Crafted with 🧵 by <a href="https://github.com/yourusername">@yourusername</a></p>
<p align="center">Crafted with 🧵 by <a href="https://github.com/Arakiss">@Arakiss</a></p>
6 changes: 3 additions & 3 deletions commitloom/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import os

# Load environment variables before any imports
env_path = Path(__file__).parent.parent / '.env'
env_path = Path(__file__).parent.parent / ".env"
load_dotenv(dotenv_path=env_path)

from .cli.main import main

if __name__ == '__main__':
main()
if __name__ == "__main__":
main()
45 changes: 37 additions & 8 deletions commitloom/cli/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
from rich.panel import Panel
from rich.prompt import Confirm, Prompt
from rich.text import Text
from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, TaskProgressColumn
from rich.progress import (
Progress,
SpinnerColumn,
TextColumn,
BarColumn,
TaskProgressColumn,
)
from typing import List, Optional

from ..core.analyzer import CommitAnalysis, WarningLevel
Expand All @@ -14,6 +20,7 @@

console = Console()


def create_progress() -> Progress:
"""Create a progress bar with custom styling."""
return Progress(
Expand All @@ -24,12 +31,16 @@ def create_progress() -> Progress:
console=console,
)


def print_changed_files(files: List[GitFile]) -> None:
"""Print list of changed files."""
console.print("\n[bold blue]📜 Changes detected in the following files:[/bold blue]")
console.print(
"\n[bold blue]📜 Changes detected in the following files:[/bold blue]"
)
for file in files:
console.print(f" - [cyan]{file.path}[/cyan]")


def print_warnings(analysis: CommitAnalysis) -> None:
"""Print analysis warnings."""
if not analysis.warnings:
Expand All @@ -45,16 +56,23 @@ def print_warnings(analysis: CommitAnalysis) -> None:
console.print(f" • Estimated cost: €{analysis.estimated_cost:.4f}")
console.print(f" • Files changed: {analysis.num_files}")


def print_batch_start(batch_num: int, total_batches: int, files: List[GitFile]) -> None:
"""Print information about starting a new batch."""
console.print(f"\n[bold blue]📦 Processing Batch {batch_num}/{total_batches}[/bold blue]")
console.print(
f"\n[bold blue]📦 Processing Batch {batch_num}/{total_batches}[/bold blue]"
)
console.print("[cyan]Files in this batch:[/cyan]")
for file in files:
console.print(f" - [dim]{file.path}[/dim]")


def print_batch_complete(batch_num: int, total_batches: int) -> None:
"""Print completion message for a batch."""
console.print(f"\n[bold green]✅ Batch {batch_num}/{total_batches} completed successfully[/bold green]")
console.print(
f"\n[bold green]✅ Batch {batch_num}/{total_batches} completed successfully[/bold green]"
)


def print_batch_summary(total_files: int, total_batches: int) -> None:
"""Print summary of batch processing plan."""
Expand All @@ -63,12 +81,14 @@ def print_batch_summary(total_files: int, total_batches: int) -> None:
console.print(f" • Number of batches: [cyan]{total_batches}[/cyan]")
console.print(f" • Files per batch: [cyan]~{total_files // total_batches}[/cyan]")


def format_cost(cost: float) -> str:
"""Format cost in both human-readable and precise formats."""
human_cost = CommitAnalyzer.format_cost_for_humans(cost)
precise_cost = f"(€{cost:.8f})"
return f"{human_cost} {precise_cost}"


def print_token_usage(usage: TokenUsage, batch_num: Optional[int] = None) -> None:
"""Print token usage summary."""
batch_info = f" (Batch {batch_num})" if batch_num is not None else ""
Expand All @@ -86,45 +106,54 @@ def print_token_usage(usage: TokenUsage, batch_num: Optional[int] = None) -> Non
"""
)


def print_commit_message(message: str) -> None:
"""Print formatted commit message."""
console.print(Panel(Text(message), expand=False, border_style="green"))


def print_batch_info(batch_number: int, files: List[str]) -> None:
"""Print information about a batch of files."""
console.print(f"\n[bold blue]📑 Batch {batch_number} Summary:[/bold blue]")
for file in files:
console.print(f" - [cyan]{file}[/cyan]")


def confirm_action(prompt: str) -> bool:
"""Ask user to confirm an action."""
return Confirm.ask(f"\n{prompt}")


def confirm_batch_continue() -> bool:
"""Ask user if they want to continue with next batch."""
return Confirm.ask("\n[bold yellow]🤔 Continue with next batch?[/bold yellow]")


def select_commit_strategy() -> str:
"""Ask user how they want to handle multiple commits."""
console.print("\n[bold blue]🤔 How would you like to handle the commits?[/bold blue]")
console.print(
"\n[bold blue]🤔 How would you like to handle the commits?[/bold blue]"
)
return Prompt.ask(
"Choose strategy",
choices=["individual", "combined"],
default="individual"
"Choose strategy", choices=["individual", "combined"], default="individual"
)


def print_success(message: str) -> None:
"""Print success message."""
console.print(f"\n[bold green]✅ {message}[/bold green]")


def print_error(message: str) -> None:
"""Print error message."""
console.print(f"\n[bold red]❌ {message}[/bold red]")


def print_info(message: str) -> None:
"""Print info message."""
console.print(f"\n[bold blue]ℹ️ {message}[/bold blue]")


def print_warning(message: str) -> None:
"""Print warning message."""
console.print(f"\n[bold yellow]⚠️ {message}[/bold yellow]")
Loading

0 comments on commit a8d5b8a

Please sign in to comment.