console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.36k stars 241 forks source link

Implement Clone for ProgressDrawTarget #532

Closed dfaust closed 1 year ago

dfaust commented 1 year ago

Uses dyn-clone to make ProgressDrawTarget and TermLike cloneable.

djc commented 1 year ago

What's your use case for this?

dfaust commented 1 year ago

This allows creating multiple progress bars within one handler, if a ProgressDrawTarget is provided. In my case, I'm watching a directory for changes and want to draw a new progress bar whenever changes are detected.

djc commented 1 year ago

Why not use a MultiProgress for that?

dfaust commented 1 year ago

In the case I mentioned, this would be possible. But it requires to pass the progress bar down to the functions that use it, instead of the draw target. I don't think that's a clean solution. I'm passing the draw target as part of a context object, and I don't want to create a progress bar just in case I might need it at some point. Another use case (that I'm not using right now) would be, to print messages between progress bars.

Are you concerned about the additional dependency? In that case I could make it optional.

djc commented 1 year ago

So why do you need to pass the ProgressDrawTarget anyway?

dfaust commented 1 year ago

So why do you need to pass the ProgressDrawTarget anyway?

I use it for testing.

djc commented 1 year ago

Okay, that doesn't do anything to convince me that this is the right solution for the problem you're trying to address. Despite me asking several questions, you've yet to state a clear picture of what it is you're trying to achieve that you think necessitates passing around a ProgressDrawTarget which doesn't seem like a common way to use our API. If you would still like to have changes made in this project, please open an issue that outlines, at a conceptual level, what you are trying to do and why other solutions aren't acceptable for this use case.