Stub out Idv parser

This commit is contained in:
Tangent 2024-07-07 21:00:20 -04:00
parent a2df9a4142
commit e90727a06c
4 changed files with 118 additions and 1 deletions
debug

43
debug/idv.ts Normal file
View file

@ -0,0 +1,43 @@
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];
}