mirror of
https://github.com/sharkdp/bat
synced 2026-08-06 19:21:43 +00:00
feat: implement --unbuffered mode for streaming input (#3555)
Repurpose the existing --unbuffered/-u flag (previously a POSIX no-op) to enable unbuffered input reading using fill_buf()/consume() instead of read_until(b'\n'). This allows partial lines to display immediately when piping streaming input like `tail -f` into bat. - Add unbuffered field to Config and InputReader - Add read_line_unbuffered() using BufRead::fill_buf()/consume() - Add flush() to OutputHandle, called after each line in unbuffered mode - Auto-disable line numbers in unbuffered mode to avoid partial line confusion - Update help text, man page, and shell completions - Add unit tests and integration tests
This commit is contained in:
+5
-2
@@ -203,8 +203,11 @@ Options:
|
||||
Display a list of supported languages for syntax highlighting.
|
||||
|
||||
-u, --unbuffered
|
||||
This option exists for POSIX-compliance reasons ('u' is for 'unbuffered'). The output is
|
||||
always unbuffered - this option is simply ignored.
|
||||
Enable unbuffered input reading. When this flag is set, bat will display data as soon as
|
||||
it is available, without waiting for a complete line. This is useful for streaming use
|
||||
cases like 'tail -f logfile | bat -u --paging=never'. Note that line numbers are
|
||||
automatically disabled in unbuffered mode, and syntax highlighting may be imperfect on
|
||||
partial lines.
|
||||
|
||||
--completion <SHELL>
|
||||
Show shell completion for a certain shell. [possible values: bash, fish, zsh, ps1]
|
||||
|
||||
@@ -58,6 +58,8 @@ Options:
|
||||
Only print the lines from N to M.
|
||||
-L, --list-languages
|
||||
Display all supported languages.
|
||||
-u, --unbuffered
|
||||
Enable unbuffered input reading for streaming use cases.
|
||||
--completion <SHELL>
|
||||
Show shell completion for a certain shell. [possible values: bash, fish, zsh, ps1]
|
||||
-E, --quiet-empty
|
||||
|
||||
Reference in New Issue
Block a user