View Source PacmanProgressBar (pacman_progress_bar v0.1.0)

This module creates a progress bar based on Arch Linux's pacman package manager

Link to this section Summary

Functions

Returns the progress bar in the form of a string

Writes the progress bar to the terminal using IO.write/2. Calling this function again will overwrite the last progress bar. If all tasks are completed it will automatically print a newline character

Link to this section Functions

Link to this function

raw(total_tasks, completed_tasks)

View Source
@spec raw(number(), number()) :: nonempty_binary()

Returns the progress bar in the form of a string

Use PacmanProgressBar.render/2 if you automatically want to write this string to the terminal

examples

Examples

iex> PacmanProgressBar.raw(30, 7)
#=> "[------c-o--o--o--o--o--o--o--]  23%"
Link to this function

render(total_tasks, completed_tasks)

View Source
@spec render(number(), number()) :: nil | :ok

Writes the progress bar to the terminal using IO.write/2. Calling this function again will overwrite the last progress bar. If all tasks are completed it will automatically print a newline character

Use PacmanProgressBar.raw/2 to get the progress bar in the form of a string

examples

Examples

iex> PacmanProgressBar.render(30, 7)
#=> [------c-o--o--o--o--o--o--o--]  23%

iex> defmodule Test do
       def function do
         PacmanProgressBar.render(30, 7)
         PacmanProgressBar.render(30, 10)
       end
     end
#=> [---------C-o--o--o--o--o--o--]  33%