Skip to content

Use fmt -w width -g width to get as close as possible to the width when wrapping lines#2431

Merged
CLHatch merged 2 commits intomainfrom
Updates
Feb 23, 2026
Merged

Use fmt -w width -g width to get as close as possible to the width when wrapping lines#2431
CLHatch merged 2 commits intomainfrom
Updates

Conversation

@CLHatch
Copy link
Contributor

@CLHatch CLHatch commented Feb 23, 2026

Pull request

Purpose
Describe the problem or feature in addition to a link to the issues.

Approach
How does this change address the problem?

Open Questions and Pre-Merge TODOs
Check all boxes as they are completed

  • Use github checklists. When solved, check the box and explain the answer.

Learning
Describe the research stage
Links to blog posts, patterns, libraries or addons used to solve this problem

Requirements
Check all boxes as they are completed

Summary by Sourcery

Improve text wrapping behavior for application descriptions and selection menus to better respect the configured column width.

Bug Fixes:

  • Adjust line wrapping of application descriptions to avoid overly short wrapped lines and better match the target width.

Enhancements:

  • Standardize use of fmt with matching width and goal options when formatting app descriptions and app name columns in interactive menus.

@CLHatch CLHatch requested a review from a team as a code owner February 23, 2026 21:50
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 23, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts line-wrapping behavior for app descriptions and app name listings by switching from simple width-based wrapping to fmt’s goal width option so wrapped text more closely matches the available column width in menu displays.

Flow diagram for env_format_lines app description wrapping

flowchart TD
  A["Get APPNAME"] --> B["Call run_script app_nicename APPNAME"]
  B --> C["Set AppName from nicename"]
  A --> D["Call run_script app_description APPNAME"]
  D --> E["Pipe description to fmt -w 75 -g 75"]
  E --> F["Set AppDescription to wrapped text"]
  F --> G["Build HeadingTitle from AppName and tags"]
  G --> H["Use HeadingTitle and AppDescription in heading output"]
Loading

Flow diagram for menu_app_select init_gauge_text name column wrapping

flowchart TD
  A["Prepare AppNamesArray"] --> B["printf each app name on its own line"]
  B --> C["Pipe to fmt -w (TextCols - AppsColumnStart) -g (TextCols - AppsColumnStart)"]
  C --> D["Pipe to pr -e -t -o AppsColumnStart for column alignment"]
  D --> E["Store result in FormattedAppNames"]
  E --> F["Display FormattedAppNames in gauge text"]
Loading

Flow diagram for menu_heading app description wrapping with goal width

flowchart TD
  A["Get ScreenCols from stty size"] --> B["Compute TextWidth = ScreenCols - WindowColsAdjust - TextColsAdjust - LabelWidth"]
  B --> C["Call fmt -w TextWidth -g TextWidth with AppDescription via here string"]
  C --> D["readarray AppDesciptionArray from fmt output"]
  D --> E["Format each element with Indent and HeadingAppDescription color"]
  E --> F["Append formatted lines and blank line to Heading Application entry"]
Loading

File-Level Changes

Change Details Files
Use fmt with both width and goal width to improve wrapping of app descriptions and app name lists to better fit UI text columns.
  • Replace fold-based wrapping of application descriptions with fmt using a fixed width and goal width of 75 characters.
  • Update formatting of the app names column to call fmt with both the computed text column width and matching goal width before columnizing with pr.
  • Adjust heading description wrapping to read lines from fmt configured with both width and goal width equal to the computed text width, ensuring more predictable wrapping in the heading display.
scripts/env_format_lines.sh
scripts/menu_app_select.sh
scripts/menu_heading.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the core Automatic label label Feb 23, 2026
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The switch from fold -s to fmt may change how existing multi-line descriptions are wrapped (e.g., merging intentional line breaks into single paragraphs); please confirm this behavior is acceptable for all current app_description outputs or consider constraining fmt usage to avoid altering paragraph structure where that matters.
  • In menu_heading.sh, the here-string invocation fmt -w ${TextWidth} -g ${TextWidth}<<< "${AppDescription}" is missing a space before <<<, which hurts readability and may trip shell tooling; update to ... -g ${TextWidth} <<< "${AppDescription}" for consistency with surrounding code.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The switch from `fold -s` to `fmt` may change how existing multi-line descriptions are wrapped (e.g., merging intentional line breaks into single paragraphs); please confirm this behavior is acceptable for all current `app_description` outputs or consider constraining `fmt` usage to avoid altering paragraph structure where that matters.
- In `menu_heading.sh`, the here-string invocation `fmt -w ${TextWidth} -g ${TextWidth}<<< "${AppDescription}"` is missing a space before `<<<`, which hurts readability and may trip shell tooling; update to `... -g ${TextWidth} <<< "${AppDescription}"` for consistency with surrounding code.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@CLHatch CLHatch merged commit 6d69a43 into main Feb 23, 2026
16 checks passed
@CLHatch CLHatch deleted the Updates branch February 23, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Automatic label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant