Skip to content

Commit

Permalink
feat: tick_by (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
miampf authored Jun 5, 2024
1 parent beba6b4 commit 6351fd2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/glitzer/progress.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub fn char_from_string(from in: String) -> Char {
}
}

/// Create a `String` from a given `Char`.
pub fn string_from_char(from in: Char) -> String {
in.char
}
Expand Down Expand Up @@ -254,6 +255,17 @@ pub fn tick(bar bar: ProgressStyle) -> ProgressStyle {
}
}

/// Increase the progress of the bar by `i`.
pub fn tick_by(bar bar: ProgressStyle, i i: Int) -> ProgressStyle {
case i > 0 {
True -> {
let bar = tick(bar)
tick_by(bar, i - 1)
}
False -> bar
}
}

/// Completely fill the progress bar.
pub fn finish(bar bar: ProgressStyle) -> ProgressStyle {
ProgressStyle(..bar, state: State(finished: True, progress: bar.length + 1))
Expand Down

0 comments on commit 6351fd2

Please sign in to comment.