Closed lucatrv closed 1 year ago
To check my understanding, you are seeing this:
Done
Test
But you are expecting this:
Done
Test
Is that right?
Yes that's correct, and now I found out that the same happens if I issue:
pb.finish_with_message("Done");
println!("Test");
So to recap, if I issue:
pb.finish_with_message("Done");
println!("Test");
or:
pb.finish_with_message("Done");
println!();
println!("Test");
or:
pb.finish_with_message("Done");
println!("\nTest");
I always get:
Done
Test
While to get a newline gap:
Done
Test
I have to issue:
pb.finish_with_message("Done");
println!();
println!("\nTest");
While to get a newline gap:
Done Test
I have to issue:
pb.finish_with_message("Done"); println!(); println!("\nTest");
OK, thanks for clarifying. I don't see any behavior out of the ordinary here, and I'd say it is working as expected. One reason why finish_with_message
doesn't automatically add a newline is that there is no requirement that the message be the last element of the progress bar. You could also do something like this:
ProgressStyle::with_template("{spinner:.bold.bright.yellow} {wide_msg} More text!")
... in which case it doesn't make sense to add \n automatically.
I agree that when the finish_with_message
is run, whatever is defined in the template should be printed out, but IMHO after everything is printed out it should also be ended with a new line character, so that the bar/spinner is actually "finished".
Considering this example:
ProgressStyle::with_template("{spinner:.bold.bright.yellow} {wide_msg} More text!")
in my opinion a new line should be added after More text!
.
Considering this example:
ProgressStyle::with_template("{spinner:.bold.bright.yellow} {wide_msg} More text!")
in my opinion a new line should be added after
More text!
.
I don't think we'll be able to change the semantics of finish_with_message
, sorry :/. Perhaps @djc can chime in. For your particular use case, I think that once #443 lands you should be able to do finish_with_message("Done\n")
to add that extra newline.
Yeah, I don't think it makes sense to change this -- in part, because there's some asymmetry here: if we print an extra newline, there's no trivial way for you to remove it, but it's usually pretty easy for you to print an extra newline.
For your particular use case, I think that once #443 lands you should be able to do
finish_with_message("Done\n")
to add that extra newline.
That would be a good solution, I tried that myself before opening this issue and it did not work. So I'll wait for #443 to be merged. Thanks!
That would be a good solution, I tried that myself before opening this issue and it did not work. So I'll wait for #443 to be merged. Thanks!
Sure thing, thanks for understanding :)
@chris-laplante thanks a lot for your support!
Just for your information, another option would be to implement a new method finish_with_message_ln
which runs finish_with_message
and then adds a newline character. If that would be interesting for you to have I can issue a pull request, otherwise I will just wait for #443 to land.
I implemented the following spinner:
Then if I issue:
I do not get the expected line gap between "Done" and "Test". To make this work I need to issue:
Apparently the
finish_with_message
method does not end its message with a newline.I'm on: