Skip to content

Iterate an list with an Progress bar #1823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Ardumine opened this issue May 21, 2025 · 1 comment
Open

Iterate an list with an Progress bar #1823

Ardumine opened this issue May 21, 2025 · 1 comment

Comments

@Ardumine
Copy link

Is your feature request related to a problem? Please describe.
I have this code that I use to show the progress of a task and I want to makeit use the progress bar of Spectre:
public static IEnumerable ProgressBar(IEnumerable values)
{
int i = 0;
foreach (var item in values)
{
yield return item;
Console.Write($"{i++}/{values.Count()}");
}
Console.WriteLine(" Done");
}

EXAMPLE:

var list = new List(){1,2,3,4,5,6,7,8};
foreach(var item in ProgressBar(list)){
...
}

Describe the solution you'd like
I want to be able to iterate trough a list/IEnumerable and get progress of that iteration.

Describe alternatives you've considered
Tried to use the AnsiConsole.Progress().Start but it creates an Func, making the yeld return not possible.

Please upvote 👍 this issue if you are interested in it.

@Elementttto
Copy link
Contributor

Hi @patriksvensson
Can I pick up this issue if nobody is working on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo 🕑
Development

No branches or pull requests

2 participants