-
Notifications
You must be signed in to change notification settings - Fork 57
[printer] Add write
method to print without a newline
#587
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the idea of supporting this sort of thing, but this example doesnt seem to work very well
#!/usr/bin/env ruby
# typed: true
require('cli/ui')
CLI::UI.frame_style = :bracket
CLI::UI::StdoutRouter.enable
CLI::UI::Frame.open('Frame 2') do
30.times do
CLI::UI.write('test')
end
end
CLI::UI::Frame.open('Frame 3') do
CLI::UI.write('test' * 20)
end
CLI::UI::Frame.open('Frame 4') do
CLI::UI.write('test' * 30)
CLI::UI.write("\n")
end
i guess i'd expect closing out the frame to inject a newline? not sure.. we've kind of avoided this up until now because of these sorts of problems. i haven't looked at how easy that would be to do. you could consider doing this manually via CLI::UI.raw
e.g.
CLI::UI::Frame.open('Frame 1') do
CLI::UI::Frame.open('Frame 2') do
CLI::UI.raw do
$stdout.write(CLI::UI::Frame.prefix)
$stdout.write('test' * 30)
$stdout.write("\n")
end
end
end
and then it's the responsibility of the caller to ensure there's a trailing newline. if we provided something like CLI::UI.write
ourselves i think it's our responsibility to ensure frames work sanely. maybe it'd make sense to have some api that automatically adds the newline at the end of the block? e.g.
CLI::UI.write_line do |io|
io.write('test' * 30)
end
the ruby + gem version bumps i think are unrelated to this change and should be split out if this pr continues
Thanks for the tips @joshheinrichs-shopify I'll PM you more details since this repo is public. |
Helps when writing in a frame.
Examples:

It's helpful because existing methods to write don't work well in frames because the beginning bar is missing. This still isn't great, but it's much better:

Bump to version
2.4.0
.Bump Ruby version to 3.3.1.