Move db to home dir and add --list subcommand

main
William Perron 2 months ago
parent 98806725a3
commit 25a6a8f6d5
No known key found for this signature in database
GPG Key ID: F701727E6034EEC9

12
incr

@ -2,10 +2,18 @@
// deno-lint-ignore-file prefer-const // deno-lint-ignore-file prefer-const
import { parseArgs } from "jsr:@std/cli"; import { parseArgs } from "jsr:@std/cli";
let db = await Deno.openKv("incrementer"); let db = await Deno.openKv("~/.incr/incr.db");
if (import.meta.main) { 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 ns = args["_"][0] ?? "_global";
let old = await db.get([ns]); let old = await db.get([ns]);

Loading…
Cancel
Save