diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-20 13:51:06 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-20 13:51:06 +0300 |
| commit | 4a8f1690c3e2e6aec34f22b516f0598c6a0da070 (patch) | |
| tree | 82ecb4568df3e91c7958c2e9f491546e6f7e9701 /internal/io/fs/directprocessor.go | |
| parent | b0a1e7928d5147d2a9fe0df710bf7c75a777e0d0 (diff) | |
Fix dcat/dgrep serverless mode to show REMOTE protocol formatrefactor-trail-1
- Add serverless flag to CatProcessor and GrepProcessor
- Format output with REMOTE|hostname|transmittedPerc|count|sourceID|content in serverless mode
- Use actual system hostname instead of "serverless" placeholder
- Preserve plain mode behavior (no formatting when --plain is used)
- Fix grep processor to properly separate multiple matched lines
- Add shared getHostname utility function
- Update tests to include serverless parameter
This fixes the regression where dcat and dgrep in serverless mode were not
showing the dtail protocol format with transmission info and status details.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/io/fs/directprocessor.go')
| -rw-r--r-- | internal/io/fs/directprocessor.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/internal/io/fs/directprocessor.go b/internal/io/fs/directprocessor.go index e02d4c2..0069397 100644 --- a/internal/io/fs/directprocessor.go +++ b/internal/io/fs/directprocessor.go @@ -115,15 +115,18 @@ func (dp *DirectProcessor) ProcessReader(ctx context.Context, reader io.Reader, } } else { // Regular write path (e.g., stdout in serverless mode) - if _, err := dp.output.Write(result); err != nil { - return err - } - - // Only add newline if the processor doesn't already handle it - // CatProcessor doesn't add newlines, but GrepProcessor does + // Check if we need to add a newline if _, isCat := dp.processor.(*CatProcessor); isCat { // Scanner strips newlines, so we need to add them back for cat - if _, err := dp.output.Write([]byte{'\n'}); err != nil { + // Combine the result with newline in a single write to avoid + // double color processing + resultWithNewline := append(result, '\n') + if _, err := dp.output.Write(resultWithNewline); err != nil { + return err + } + } else { + // For other processors, just write the result as-is + if _, err := dp.output.Write(result); err != nil { return err } } |
