Improve word wrapping of long lines
Swiftly has some long lines of text and currently relies on the shell to do the wrapping. Most shells do a bad job of wrapping at word boundaries, so words get chopped in the middle, which is not a great experience.
Instead, swiftly can use the same approach as the argument parser where it can attempt to detect the terminal width, and wrap lines around word boundaries. Here is the relevant code in the swift-argument-parser:
https://github.com/apple/swift-argument-parser/blob/d67151befa39533a6a449136c7992537cbf8ec99/Sources/ArgumentParser/Utilities/Platform.swift#L189 https://github.com/apple/swift-argument-parser/blob/d67151befa39533a6a449136c7992537cbf8ec99/Sources/ArgumentParser/Utilities/StringExtensions.swift#L13-L55
This shouldn't be a large change since it can be put into the SwiftlyCore.print() function that's used whenever output is being emitted.
There are some cases where the lines shouldn't be wrapped, such as command-lines. Also, there are some cases where the print is called with pre-wrapped lines for simple prose. These should rely on the new print functionality to wrap based on the terminal width.
Hi @cmcgee1024
Can I work on this?
@roulpriya, yes, I've assigned this issue to you since I can see that you've got a PR ready for it.
Can you please review the PR?
@roulpriya I think that this can be closed now since you've implemented the wrapping feature with the linked PR's.
Sure, we can close it.