Skip to content

Conversation

evanliu048
Copy link
Contributor

@evanliu048 evanliu048 commented Sep 9, 2025

Issue #, if available:
Q cli currently applies automatic line wrapping at ~80 characters regardless of output destination if cannot obtain current terminal width, which causes issues in non-interactive workflows. When output is piped or redirected, the forced line breaks make it difficult to process the text programmatically and ignore explicit user formatting requests (e.g., "write in a single line").
For example
before

Description of changes:
Added a --wrap-mode option with three modes:

  • auto (default): Wraps for terminal display, no wrapping for pipes/files
  • always: Always wrap at terminal width
  • never: Never wrap output

The default auto mode follows Unix conventions by detecting if stdout is a terminal, providing readable output for interactive use while preserving raw format for automation.

Usage

# Default behavior (auto-detect)
q chat --no-interactive "text"           # Terminal: wraps
q chat --no-interactive "text" | cat     # Pipe: no wrapping

# Explicit control
q chat --no-interactive --wrap=never "text"
q chat --w always

Wrap mode = never
never

Testing

Tested with various output destinations (terminal, pipe, file redirection) to ensure correct behavior in each mode.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@evanliu048 evanliu048 marked this pull request as draft September 9, 2025 01:00
@evanliu048 evanliu048 changed the title Fix: Add configurable line wrapping for non-interactive mode Fix: Add configurable line wrapping for chat Sep 9, 2025
@evanliu048 evanliu048 marked this pull request as ready for review September 9, 2025 23:35
@evanliu048 evanliu048 merged commit 5ea7045 into main Sep 10, 2025
14 of 15 checks passed
@evanliu048 evanliu048 deleted the revise_word_wrapping branch September 10, 2025 22:07
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