progress

progress
git clone git://brookjeynes.dev/bjeynes/progress.git
Log | Files | Refs | README | LICENSE

commit 97443dadde9cccb852845f4f6ef2533102333d50
parent 49bcc8df9df3a0ed4b011a1fe6297faa490d3095
Author: brookjeynes <me@brookjeynes.dev>
Date:   Fri,  5 Jun 2026 07:51:45 +1000

docs: update readme and add example gif in repo

Diffstat:
AREADME | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aexample.gif | 0
2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,56 @@ +progress +======== + +Thread safe progress bar and spinner library. + + +Installation +------------ +1. Fetch the package + zig fetch --save git+https://github.com/BrookJeynes/progress + +2. Add to your build.zig + const progress = b.dependency("progress", .{}).module("progress"); + exe.root_module.addImport("progress", progress); + +This project is built using the latest stable release of Zig at the time of +writing (v0.16.0) + + +Usage +----- + +More examples can be found in examples/ + +const std = @import("std"); +const ProgressBar = @import("progress").Bar; +const ProgressSpinner = @import("progress").Spinner; + +pub fn bar() !void { + const stdout = std.io.getStdOut().writer(); + var pb = ProgressBar.init(10, stdout.any(), .{}); + + while (!pb.isFinished()) { + pb.add(1); + try pb.render(); + + std.time.sleep(std.time.ns_per_ms * 150); + } +} + +pub fn spinner() !void { + const stdout = std.io.getStdOut().writer(); + var ps = ProgressSpinner.init(stdout.any(), .{ + .symbols = ProgressSpinner.PredefinedSymbols.default, + }); + + var iterations: usize = 0; + while (!ps.isFinished()) { + iterations += 1; + try ps.render(); + + if (iterations == 20) try ps.finish(); + + std.time.sleep(std.time.ns_per_ms * 150); + } +} diff --git a/example.gif b/example.gif Binary files differ.