-
Notifications
You must be signed in to change notification settings - Fork 622
Description
Is your feature request related to a problem? Please describe.
In my current project, I need to have a precise elapsed time column for my progress tasks, but they are all shown as 00:00:00 because there are too quick, and I need to see the ms also.
Describe the solution you'd like
I've changed the ProgressTask.StartTime & ProgressTask.StopTime properties to long? then use the new API from .NET8: TimeProvider.System.GetTimestamp() & TimeProvider.System.GetElapsedTime()
Describe alternatives you've considered
I didn't see any alternatives.
Additional context
Before:
Getting Infos ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00
Getting input ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00
Create Solution ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00
Solving ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00
Sending ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00
After:
Getting Infos ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00.6375067
Getting input ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00.5368024
Create Solution ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00.0022177
Solving ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00.5746945
Sending ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00:00.0022711
await AnsiConsole.Progress()
.Columns([
new TaskDescriptionColumn(),
new ProgressBarColumn(),
new ElapsedTimeColumn() { Format = null }, // change the new Format property
]).StartAsync(...);ElepsedTimeColumn.cs
public string? Format { get; set; } = @"hh\:mm\:ss";
public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
{
// ...
return new Text($"{elapsed.Value.ToString(Format)}", Style ?? Style.Plain);
}I'm already using the modified version in my project flawlessly and am able to create the PR now.
All the tests run fine.
Please upvote 👍 this issue if you are interested in it.