From 25a6a8f6d5d97cf005ea3fb995509cdea3b8beb7 Mon Sep 17 00:00:00 2001 From: William Perron Date: Thu, 28 Nov 2024 10:30:04 -0500 Subject: [PATCH] Move db to home dir and add --list subcommand --- incr | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/incr b/incr index 574a8c3..26bf924 100755 --- a/incr +++ b/incr @@ -2,10 +2,18 @@ // deno-lint-ignore-file prefer-const import { parseArgs } from "jsr:@std/cli"; -let db = await Deno.openKv("incrementer"); +let db = await Deno.openKv("~/.incr/incr.db"); if (import.meta.main) { - let args = parseArgs(Deno.args); + let args = parseArgs(Deno.args, {boolean: ["list"]}); + if (args["list"]) { + let iter = db.list({ prefix: [] }); + for await (const res of iter) { + console.log(`${res.key}: ${res.value}`); + } + Deno.exit(0); + } + let ns = args["_"][0] ?? "_global"; let old = await db.get([ns]);