README.md (1640B)
1 # progress 2 3  4 5 A simple thread safe progress bar and spinner library. 6 7 - [Installation](#installation) 8 - [Example](#example) 9 - [Contributing](#contributing) 10 11 ## Installation 12 1. Fetch the package. 13 `zig fetch --save git+https://github.com/BrookJeynes/progress` 14 2. Add to your `build.zig`. 15 ```zig 16 const progress = b.dependency("progress", .{}).module("progress"); 17 exe.root_module.addImport("progress", progress); 18 ``` 19 20 ## Example 21 ```zig 22 const std = @import("std"); 23 const ProgressBar = @import("progress").Bar; 24 const ProgressSpinner = @import("progress").Spinner; 25 26 pub fn bar() !void { 27 const stdout = std.io.getStdOut().writer(); 28 var pb = ProgressBar.init(10, stdout.any(), .{}); 29 30 while (!pb.isFinished()) { 31 pb.add(1); 32 try pb.render(); 33 34 std.time.sleep(std.time.ns_per_ms * 150); 35 } 36 } 37 38 pub fn spinner() !void { 39 const stdout = std.io.getStdOut().writer(); 40 var ps = ProgressSpinner.init(stdout.any(), .{ 41 .symbols = ProgressSpinner.PredefinedSymbols.default, 42 }); 43 44 var iterations: usize = 0; 45 while (!ps.isFinished()) { 46 iterations += 1; 47 try ps.render(); 48 49 if (iterations == 20) try ps.finish(); 50 51 std.time.sleep(std.time.ns_per_ms * 150); 52 } 53 } 54 ``` 55 56 You can find more examples in the `examples/` folder. 57 For more information, see the source code or documentation (`zig build docs`). 58 59 ## Contributing 60 Contributions, issues, and feature requests are always welcome! This project is 61 using the latest stable release of Zig (0.16.0).