From c1d7cb100a522271a3957ced9813663d64bfccd4 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Tue, 06 Oct 2026 18:28:54 +0000
Subject: [PATCH] adding searchUsers.js
---
bin/searchUsers.js | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/bin/searchUsers.js b/bin/searchUsers.js
new file mode 100644
index 0000000..e5888a0
--- /dev/null
+++ b/bin/searchUsers.js
@@ -0,0 +1,38 @@
+const db = require("../lib/db")
+const searchLib = require("../lib/search")
+const yargs = require("yargs")
+
+/////////////////////////////////////////////////////////////////////////
+
+const argv = yargs
+ .usage("$0 <search> [offset] [limit]", "search users",)
+ .option("ids-only", {
+ describe: "only print matching usr_ids",
+ type: "boolean",
+ default: false,
+ })
+ .strict()
+ .parse()
+
+run(argv)
+ .then(print)
+ .catch(console.error)
+ .finally(process.exit)
+
+async function run({search, offset, limit, idsOnly}) {
+ if (idsOnly) {
+ return await searchLib.search(String(search))
+ }
+ offset = offset || 0
+ limit = limit || 20
+ return await db.getUsers(offset, limit, String(search))
+}
+
+function print (res) {
+ if (Array.isArray(res)) {
+ console.log(res)
+ return
+ }
+ const {total, offset, limit, data} = res
+ console.log({data, count: data.length, total, offset, limit})
+}
--
Gitblit v1.8.0