Skip to content

Step Sequence

StepSequence runs an ordered list of steps, each backed by a spinner or a progress bar, with success/failure/skip states and a summary.

zig
const seq = try loaders.StepSequence.init(allocator, io, config);

Config

zig
pub const StepSequenceConfig = struct {
    interval_ms: u32 = 60,
};

Types

zig
pub const StepStatus = enum { pending, running, completed, failed, skipped };

pub const StepKind = union(enum) {
    spinner: SpinnerConfig,
    bar: ProgressBarConfig,
};

pub const StepConfig = struct {
    name: []const u8,
    kind: StepKind,
};

Methods

MethodDescription
init(allocator, io, config) !StepSequenceCreate.
deinit()Stop the render thread (if any).
addStep(StepConfig) !usizeAdd a step; returns its index.
startStep(index) !voidStart a step.
completeStep(index, FinishConfig)Mark a step completed (with final_text/newline).
failStep(index, ?message)Mark a step failed, optionally with a message.
skipStep(index)Mark a step skipped.
runAll(context, runner)Run every step; runner: *const fn (?*anyopaque, []const u8) void receives the step name.
statusOf(index) StepStatusStatus of a step.
barOf(index) *ProgressBarThe bar widget of a bar step.
spinnerOf(index) *SpinnerThe spinner widget of a spinner step.
printSummary()Print a checkmark/cross summary of all steps.

Example

zig
var seq = try loaders.StepSequence.init(allocator, io, .{});
defer seq.deinit();

_ = try seq.addStep(.{ .name = "Install", .kind = .{ .spinner = .{
    .frames = &.{ ".", "..", "..." },
    .template = "{frame} Installing...",
} } });
_ = try seq.addStep(.{ .name = "Build", .kind = .{ .bar = .{
    .total = 100,
    .template = "{bar} {percent}%",
} } });

try seq.startStep(0);
// ... do work ...
seq.completeStep(0, .{});

Released under the MIT License.