From 569e3424e9c56e6b80a3f31311a84e5381fa0aa5 Mon Sep 17 00:00:00 2001 From: Agil Mammadov Date: Sat, 9 May 2026 22:31:25 +0400 Subject: [PATCH 1/2] feat(search): add --limit / -n flag to cap result count --- nnote/commands/search.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nnote/commands/search.py b/nnote/commands/search.py index bd19db1..e132815 100644 --- a/nnote/commands/search.py +++ b/nnote/commands/search.py @@ -13,7 +13,14 @@ help="Scope search to a subdirectory", shell_complete=complete_directories, ) -def search(query, directory): +@click.option( + "-n", + "--limit", + default=None, + type=click.IntRange(min=1), + help="Maximum number of results to show", +) +def search(query, directory, limit): """Search notes by title and content.""" config = Config.load() @@ -28,6 +35,8 @@ def search(query, directory): raise click.ClickException(f"Directory not found: {root}") results = search_notes(root, query) + if limit is not None: + results = results[:limit] if not results: click.echo("No notes found.") From 39f79c6c80ed10b77c249a3c6555599dae6cb900 Mon Sep 17 00:00:00 2001 From: Agil Mammadov Date: Sat, 9 May 2026 22:33:14 +0400 Subject: [PATCH 2/2] docs(search): document --limit flag --- docs/commands/search.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/commands/search.rst b/docs/commands/search.rst index 007afa9..d4a1ee7 100644 --- a/docs/commands/search.rst +++ b/docs/commands/search.rst @@ -3,16 +3,19 @@ nnote search .. code-block:: text - nnote search [-d ] + nnote search [-d ] [-n ] Search notes by title and content. Results are ranked by relevance: exact title matches score highest, followed by prefix/substring/fuzzy title matches, then content hits. Matched terms are highlighted in the output. +Use ``-n`` / ``--limit`` to cap the number of results shown. + .. code-block:: bash nnote search meeting nnote search budget -d work + nnote search todo -n 5 ::