Skip to content

Prevent wrapping of post installation script in swiftly init#500

Merged
cmcgee1024 merged 3 commits intoswiftlang:mainfrom
cmcgee1024:apt-line-truncated
Feb 4, 2026
Merged

Prevent wrapping of post installation script in swiftly init#500
cmcgee1024 merged 3 commits intoswiftlang:mainfrom
cmcgee1024:apt-line-truncated

Conversation

@cmcgee1024
Copy link
Member

No description provided.

""")
"""

if ctx.format == .text {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just call ctx.message here? Isn't the conditional for the format handled there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good point. Maybe ctx.message should internally make the switch between stdout/stderr instead of requiring clients to do that.

// This is a plain print instead of a ctx.message to avoid line wrapping of the
// post install script. When it is wrapped then it is harder to copy and paste
// the contents from the terminal.
print("\(Messages.postInstall(postInstall))")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make more sense to just pretend a newline to this message and still rely on ctx.message? Just thinking about if a user is using json output

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try another pass on this by abstracting JSON output/text (stderr/stdout), and provide a flag that allows the client to indicate whether auto-word wrapping should be disabled for a particular string.

Copy link
Contributor

@justice-adams-apple justice-adams-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine for now, though I wonder if we do want it to wrap, but escape the newlines correctly? e.g

% apt-get install -y \
  blah \
  blah \
  blah

I think that is more legible than the wall of text. Thoughts?

@cmcgee1024
Copy link
Member Author

I generally like the idea of escaping the newlines of commands so that each argument can be considered. In this case it's probably not as important to most users each individual package as it is that there are packages that need to be installed by the system package manager, so it's probably not as important to devote a line to each package.

@cmcgee1024 cmcgee1024 merged commit 2fc7916 into swiftlang:main Feb 4, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants