From b7e539de3b908073667898b831a6646b244e4007 Mon Sep 17 00:00:00 2001 From: Uyanide Date: Thu, 9 Apr 2026 23:39:01 +0200 Subject: [PATCH] feat: add --no-newline option for watch pipe --- src/lrx_cli/cli.py | 16 +++++++++++++--- src/lrx_cli/watch/view/pipe.py | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lrx_cli/cli.py b/src/lrx_cli/cli.py index 95c2f45..b3a9628 100644 --- a/src/lrx_cli/cli.py +++ b/src/lrx_cli/cli.py @@ -390,24 +390,34 @@ def pipe( before: Annotated[ int, cyclopts.Parameter( - name="--before", + name=["--before", "-b"], help="Number of lyric lines to show before current line.", ), ] = 0, after: Annotated[ int, cyclopts.Parameter( - name="--after", + name=["--after", "-a"], help="Number of lyric lines to show after current line.", ), ] = 0, + no_newline: Annotated[ + bool, + cyclopts.Parameter( + name=["--no-newline", "-n"], + negative="", + help="Do not append a new line after the lyric output.", + ), + ] = False, ): """Watch active player and continuously print lyric window to stdout.""" logger.info( "Starting watch pipe (player filter: {})", _player or "", ) - output = PipeOutput(before=max(0, before), after=max(0, after)) + output = PipeOutput( + before=max(0, before), after=max(0, after), no_newline=no_newline + ) try: session = WatchCoordinator( manager, diff --git a/src/lrx_cli/watch/view/pipe.py b/src/lrx_cli/watch/view/pipe.py index e105510..e170bb3 100644 --- a/src/lrx_cli/watch/view/pipe.py +++ b/src/lrx_cli/watch/view/pipe.py @@ -13,6 +13,7 @@ class PipeOutput(BaseOutput): before: int = 0 after: int = 0 + no_newline: bool = False def _window_size(self) -> int: """Return rendered lyric window size.""" @@ -81,5 +82,5 @@ class PipeOutput(BaseOutput): lines = self._render_lyrics(state) for line in lines: - print(line) + sys.stdout.write(line + ("\n" if not self.no_newline else "")) sys.stdout.flush()