From 37d29fc6ad62274038f6ba1efe436265e2849ec5 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sun, 13 Jul 2025 20:12:22 +0200 Subject: [PATCH] cli/query_word: add flags for pagination --- lib/cli/commands/query_word.dart | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/cli/commands/query_word.dart b/lib/cli/commands/query_word.dart index 45219da..09853f4 100644 --- a/lib/cli/commands/query_word.dart +++ b/lib/cli/commands/query_word.dart @@ -22,6 +22,19 @@ class QueryWord extends Command { abbr: 'j', help: 'Output results in JSON format', ); + + argParser.addOption( + 'page', + abbr: 'p', + valueHelp: 'NUM', + defaultsTo: '1', + ); + + argParser.addOption( + 'pageSize', + valueHelp: 'NUM', + defaultsTo: '30', + ); } Future run() async { @@ -59,6 +72,8 @@ class QueryWord extends Command { db, searchWord, argResults!.flag('json'), + int.parse(argResults!.option('page')!), + int.parse(argResults!.option('pageSize')!), ); } } @@ -89,13 +104,19 @@ class QueryWord extends Command { DatabaseExecutor db, String searchWord, bool jsonOutput, + int page, + int pageSize, ) async { final time = Stopwatch()..start(); final count = await JaDBConnection(db).jadbSearchWordCount(searchWord); time.stop(); final time2 = Stopwatch()..start(); - final result = await JaDBConnection(db).jadbSearchWord(searchWord); + final result = await JaDBConnection(db).jadbSearchWord( + searchWord, + page: page, + pageSize: pageSize, + ); time2.stop(); if (result == null) {