-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompilation-spinner.cs
More file actions
36 lines (29 loc) · 869 Bytes
/
Copy pathcompilation-spinner.cs
File metadata and controls
36 lines (29 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#:package PrettyConsole@6.0.0
using System.Diagnostics;
using PrettyConsole;
string[] steps = [
"Restore",
"Compile",
"Link native shims",
"Run analyzers",
"Pack artifacts",
];
var step = 0;
var start = Stopwatch.GetTimestamp();
var build = Task.Run(async () => {
for (; step < steps.Length; Interlocked.Increment(ref step)) {
await Task.Delay(800);
}
});
var spinner = new Spinner {
Pattern = Spinner.Patterns.Braille,
ForegroundColor = Color.Green,
DisplayElapsedTime = true,
UpdateRate = 100,
};
await spinner.RunAsync(build, (builder, out handler) => {
var current = Volatile.Read(ref step);
handler = builder.Build(OutputPipe.Error, $"Current step: {Color.Green}{steps[current]}");
}, CancellationToken.None);
var elapsed = Stopwatch.GetElapsedTime(start);
Console.WriteLineInterpolated($"Build complete in {Color.Green}{elapsed:duration}");