2024-07-07 21:00:20 -04:00
|
|
|
import { h } from "../lib/html";
|
2024-07-19 23:41:11 -04:00
|
|
|
import { Idv, StringProperty } from "../lib/idv";
|
2024-07-07 21:00:20 -04:00
|
|
|
|
|
|
|
export function IdvDebug() {
|
|
|
|
const textarea = h(
|
|
|
|
"textarea",
|
|
|
|
{
|
|
|
|
cols: 80,
|
|
|
|
rows: 40,
|
|
|
|
oninput(ev) {
|
|
|
|
parse();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`# Idv Testing Ground
|
2024-07-10 00:31:33 -04:00
|
|
|
User: tangent128
|
|
|
|
Uid: 10000
|
|
|
|
Shell: tclsh
|
|
|
|
Group: users
|
|
|
|
Group: sudo
|
|
|
|
Banner:
|
|
|
|
+------------------+
|
|
|
|
|Welcome to Debian!|
|
|
|
|
+------------------+
|
|
|
|
|
|
|
|
User: tirga
|
|
|
|
Uid: 10101
|
|
|
|
Shell: bash
|
|
|
|
Group: users
|
|
|
|
`
|
2024-07-07 21:00:20 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
const pre = h("pre");
|
|
|
|
|
|
|
|
function parse() {
|
|
|
|
try {
|
|
|
|
const idv = Idv.parse(textarea.value);
|
|
|
|
|
|
|
|
pre.textContent = JSON.stringify(
|
2024-07-14 22:19:26 -04:00
|
|
|
idv.getMergedMap("User", UserFromDocument),
|
2024-07-07 21:00:20 -04:00
|
|
|
null,
|
|
|
|
2
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
pre.textContent = String(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parse();
|
|
|
|
|
|
|
|
return [textarea, pre];
|
|
|
|
}
|
2024-07-10 00:31:33 -04:00
|
|
|
|
2024-07-14 22:19:26 -04:00
|
|
|
const UserFromDocument = (idv: Idv) => {
|
2024-07-10 00:31:33 -04:00
|
|
|
return {
|
2024-07-19 23:41:11 -04:00
|
|
|
shell: idv.getProperty("Shell", StringProperty),
|
|
|
|
groups: idv.getList("Group", StringProperty),
|
|
|
|
banner: idv.getProperty("Banner", StringProperty),
|
2024-07-10 00:31:33 -04:00
|
|
|
};
|
|
|
|
};
|