glitzer/progress

Types

Char

opaque

A String with only one character.

pub opaque type Char

The style of a progress bar.

pub opaque type ProgressStyle

State

opaque
pub opaque type State

Functions

pub fn char_from_string(from in: String) -> Char

Create a Char from a String. Returns a Char with the given string if the strings length is equal to one and a Char of “#” otherwise.

Example:
import glitzer/progress

fn example() {
  let char = progress.char_from_string("A")
}
pub fn default_bar() -> ProgressStyle

Create and return a default progress bar.

pub fn each_iterator(
  over i: Iterator(a),
  bar bar: ProgressStyle,
  with fun: fn(ProgressStyle, a) -> b,
) -> Nil
pub fn fancy_slim_arrow_bar() -> ProgressStyle

Create and return a fancy and slim progress bar with an arrow head.

pub fn fancy_slim_bar() -> ProgressStyle

Create and return a fancy and slim progress bar (inspired by pip).

pub fn fancy_thick_bar() -> ProgressStyle

Create and return a fancy thick bar.

pub fn finish(bar bar: ProgressStyle) -> ProgressStyle

Completely fill the progress bar.

pub fn map2_iterator(
  iterator1 i1: Iterator(a),
  iterator2 i2: Iterator(b),
  bar bar: ProgressStyle,
  with fun: fn(ProgressStyle, a, b) -> c,
) -> Iterator(c)
pub fn map_iterator(
  over i: Iterator(a),
  bar bar: ProgressStyle,
  with fun: fn(ProgressStyle, a) -> b,
) -> Iterator(b)

Map an iterator to a function with a bar that ticks every run of the function.

Example:
import glitzer/progress

fn example(bar) {
  iterator.range(0, 100)
  |> progress.map_iterator(fn(bar, element) {
    progress.print_bar(bar)
    // do some heavy calculations here >:)
  })
}
pub fn new_bar() -> ProgressStyle

Create a new (completely empty) progress bar.

Example:
import glitzer/progress

fn example() {
  let bar = 
    progress.new_bar()
    |> progress.with_length(50)
    |> progress.with_left_text("Progress: ")
    |> progress.with_fill(progress.char_from_string("+"))
}
pub fn print_bar(bar bar: ProgressStyle) -> Nil

Print the progress bar to stderr.

Example:
import glitzer/progress

fn example() {
  let bar = progress.default_bar()

  run_example(bar, 0)
}

fn run_example(bar, count) {
  case count < 100 {
    True -> {
      let bar = progress.tick(bar)
      // do some awesome stuff :3
      progress.print_bar(bar)
      run_example(bar, count + 1)
    }
    False -> Nil
  }
}
pub fn slim_bar() -> ProgressStyle

Create and return a fancy and slim progress bar (inspired by pip).

pub fn string_from_char(from in: Char) -> String

Create a String from a given Char.

pub fn thick_bar() -> ProgressStyle

Create and return a thick bar.

pub fn tick(bar bar: ProgressStyle) -> ProgressStyle

Increase the progress of the bar by one.

pub fn tick_by(bar bar: ProgressStyle, i i: Int) -> ProgressStyle

Increase the progress of the bar by i.

pub fn with_empty(
  bar bar: ProgressStyle,
  empty char: Char,
) -> ProgressStyle

Add a character to a progress bar that is used to represent the “background” of the bar.

pub fn with_fill(
  bar bar: ProgressStyle,
  fill char: Char,
) -> ProgressStyle

Add a character to a progress bar that is used to fill the bar on each tick.

pub fn with_fill_finished(
  bar bar: ProgressStyle,
  fill char: Char,
) -> ProgressStyle

Add a character that will be used instead of fill if the bar is finished.

pub fn with_fill_head(
  bar bar: ProgressStyle,
  fill char: Char,
) -> ProgressStyle

Add a head to the progress bar.

pub fn with_fill_head_finished(
  bar bar: ProgressStyle,
  fill char: Char,
) -> ProgressStyle

Add a head to the progress bar that will be displayed when the bar finishes.

pub fn with_left_text(
  bar bar: ProgressStyle,
  left text: String,
) -> ProgressStyle

Add left text to a progress bar.

pub fn with_length(
  bar bar: ProgressStyle,
  length len: Int,
) -> ProgressStyle

Add length to a progress bar.

pub fn with_right_text(
  bar bar: ProgressStyle,
  right text: String,
) -> ProgressStyle

Add right text to a progress bar.

Search Document