2024.js/debug/idv.ts

44 lines
767 B
TypeScript
Raw Normal View History

2024-07-07 21:00:20 -04:00
import { h } from "../lib/html";
import { Idv, StringFromDocument } from "../lib/idv";
export function IdvDebug() {
const textarea = h(
"textarea",
{
cols: 80,
rows: 40,
oninput(ev) {
parse();
},
},
`# Idv Testing Ground
Uid: 0
Shell: tclsh
Group: users
Group: sudo
`
);
const pre = h("pre");
function parse() {
try {
const idv = Idv.parse(textarea.value);
pre.textContent = JSON.stringify(
{
shell: idv.getProperty("Shell", String, StringFromDocument),
groups: idv.getList("Group", String, StringFromDocument),
},
null,
2
);
} catch (e) {
pre.textContent = String(e);
}
}
parse();
return [textarea, pre];
}