Alaja.Components.Bar (Alaja v2.2.0)

Copy Markdown View Source

Static progress bar component for terminal output.

Renders a horizontal bar representing a value as a proportion of a maximum.

Usage

iex> Alaja.Components.Bar.print(75, 100)
# [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░] 75%

iex> Alaja.Components.Bar.print(0.6, 1.0, label: "CPU", width: 40)
# CPU [▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░] 60%

Cell engine

As of v0.3.0, render/3 returns an Alaja.Buffer.t/0. The label and percent text are placed on the same row as the bar (left-aligned label, right-aligned percent).

Summary

Functions

Prints a progress bar directly to stdout.

Renders a progress bar to an Alaja.Buffer.t/0.

Functions

print(value, max \\ 100, opts \\ [])

@spec print(number(), number(), keyword()) :: :ok

Prints a progress bar directly to stdout.

render(value, max \\ 100, opts \\ [])

@spec render(number(), number(), keyword()) :: Alaja.Buffer.t()

Renders a progress bar to an Alaja.Buffer.t/0.

Layout (single row, total width = label_w + 1 + width + 1 + percent_w): [label ] [bar] [percent]