cli/query_word: add flags for pagination

This commit is contained in:
2025-07-13 20:12:22 +02:00
parent 60898fe9a2
commit 37d29fc6ad

View File

@@ -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<void> 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) {