From 9e1f5526f93a85c8c944b947949ccaffd5bbe15b Mon Sep 17 00:00:00 2001 From: Agil Mammadov Date: Sat, 9 May 2026 22:44:25 +0400 Subject: [PATCH 1/2] feat(view): add --pager flag to pipe output through $PAGER --- nnote/commands/view.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nnote/commands/view.py b/nnote/commands/view.py index ab7cc78..6f38a61 100644 --- a/nnote/commands/view.py +++ b/nnote/commands/view.py @@ -13,7 +13,13 @@ help="Subdirectory within notes dir", shell_complete=complete_directories, ) -def view(title, directory): +@click.option( + "--pager", + is_flag=True, + default=False, + help="Pipe output through $PAGER (defaults to less)", +) +def view(title, directory, pager): """Print the contents of a note.""" config = Config.load() note_path = resolve_note_path(config, title, directory) @@ -21,4 +27,8 @@ def view(title, directory): if not note_path.exists(): raise click.ClickException(f"Note not found: {note_path}") - click.echo(note_path.read_text(encoding="utf-8"), nl=False) + content = note_path.read_text(encoding="utf-8") + if pager: + click.echo_via_pager(content) + else: + click.echo(content, nl=False) From 99574f0d6d2153cef2818027a781a94869d0010e Mon Sep 17 00:00:00 2001 From: Agil Mammadov Date: Sat, 9 May 2026 22:44:49 +0400 Subject: [PATCH 2/2] docs(view): document --pager flag --- docs/commands/view.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/commands/view.rst b/docs/commands/view.rst index c8b4446..4e4670a 100644 --- a/docs/commands/view.rst +++ b/docs/commands/view.rst @@ -3,11 +3,15 @@ nnote view .. code-block:: text - nnote view [-d <dir>] + nnote view <title> [-d <dir>] [--pager] Print the contents of a note to stdout. +Use ``--pager`` to pipe the output through a pager (``$PAGER``, falling back +to ``less``). Useful for long notes. + .. code-block:: bash nnote view todo nnote view standup -d work + nnote view meeting-notes --pager