|
|
@ -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]);
|
|
|
|