-
Notifications
You must be signed in to change notification settings - Fork 70
add read tool formatters #1016
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: 06-30/pi-tool-formatter-bash
Are you sure you want to change the base?
add read tool formatters #1016
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,23 @@ def format_bash | |
| ok_line("#{count} #{"line".pluralize(count)}", preview) | ||
| end | ||
|
|
||
| # Formats a read tool result. | ||
| # | ||
| # Content: the file's text. | ||
| # | ||
| # Output: "READ OK <n> <line|lines>" – <n> is the line count (pluralized). | ||
| # | ||
| # Examples: | ||
| # READ OK 42 lines | ||
| # READ OK 1 line | ||
| # READ OK 0 lines | ||
| # | ||
| #: () -> String | ||
| def format_read | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Counting inconsistency with the later sibling formatters. This counts |
||
| count = content.to_s.lines.length | ||
| ok_line("#{count} #{"line".pluralize(count)}") | ||
| end | ||
|
|
||
| # Formats a result for which Roast has no dedicated formatter. | ||
| # | ||
| # Content: the tool's output text. | ||
|
|
||
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.
Edge case: with
limit: 0this renders(lines 1–0)— a backwards range (offset + limit - 1=1 + 0 - 1= 0).limit: 0isn't obviously invalid input from Pi. Minor, but alimit.positive?guard (or documenting that limit is assumed ≥1) avoids the inverted range.