Skip to content

Commit

Permalink
FEAT: Integrate 'rich' library for enhanced CLI output formatting and…
Browse files Browse the repository at this point in the history
… update dependencies
  • Loading branch information
pablofueros committed Jan 28, 2025
1 parent 8123a98 commit 658a535
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies = [
"plotly>=5.24.1",
"polars>=1.20.0",
"pydantic-xml>=2.14.1",
"rich>=13.9.4",
"typer>=0.15.1",
]

Expand Down
14 changes: 8 additions & 6 deletions src/bbrpy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import plotly.express as px
import polars as pl
import rich
import typer

from .models import BatteryReport
Expand Down Expand Up @@ -34,10 +35,12 @@ def main(
def info():
"""Display basic battery information from the latest report."""
battery_report = BatteryReport.generate()
typer.echo(f"Computer Name: {battery_report.computer_name}")
typer.echo(f"Scan Time: {battery_report.scan_time}")
typer.echo(f"Design Capacity: {battery_report.design_cap} mWh")
typer.echo(f"Full Charge Capacity: {battery_report.full_cap} mWh")
rich.print(f":computer: Computer Name: [red]{battery_report.computer_name}[/red]")
rich.print(f":alarm_clock: Scan Time: [green]{battery_report.scan_time}[/green]")
rich.print(
f":battery: Capacity Status: "
f"{battery_report.full_cap}/{battery_report.design_cap} mWh"
)


@app.command()
Expand Down Expand Up @@ -67,8 +70,7 @@ def generate(

# Save the report to an HTML file
fig.write_html(output_path.with_suffix(".html"))
styled_dir = typer.style(str(directory), fg=typer.colors.BLUE)
typer.echo(f"Report generated successfully in {styled_dir}")
rich.print(f"Report generated successfully in [blue]{directory}[/blue]")

# Open the report in the default browser
webbrowser.open(f"file://{output_path}")
Expand Down
6 changes: 4 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 658a535

Please sign in to comment.