mirror of
https://git.ari.lt/ari.lt/ari.lt.git
synced 2025-02-04 09:39:25 +01:00
js/term : add more commands
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
parent
43f804babd
commit
f3a4bfb29b
4 changed files with 46 additions and 3 deletions
|
@ -41,3 +41,5 @@ const EXTRA_PAGES = [
|
|||
"/git",
|
||||
"/user",
|
||||
];
|
||||
|
||||
const DO_FETCH = true;
|
||||
|
|
|
@ -35,6 +35,8 @@ async function main() {
|
|||
document.getElementById("blog-link").href = BLOG_SITE;
|
||||
document.getElementById("comments-link").href = COMMENT_SITE;
|
||||
|
||||
if (!DO_FETCH) return;
|
||||
|
||||
FETCH_BLOG_POSTS().then((j) => {
|
||||
blog.innerText = "";
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ function cmd_help() {
|
|||
.forEach((cmd) => mkelem("li", cmd, ul));
|
||||
|
||||
return [
|
||||
"congratulations, you are now in the ari-web terminal\nheres some commands : ",
|
||||
"congratulations, you are now in the ari-web terminal\nheres some commands :\n\n",
|
||||
ul,
|
||||
];
|
||||
}
|
||||
|
@ -29,3 +29,36 @@ function cmd_clear(_, hist) {
|
|||
hist.innerHTML = "";
|
||||
return [];
|
||||
}
|
||||
|
||||
function cmd_echo(args) {
|
||||
return [args];
|
||||
}
|
||||
|
||||
function cmd_webfetch() {
|
||||
let head = `user@${SITE_NAME}`;
|
||||
|
||||
return [
|
||||
`\`8.\`888b ,8' ${head}
|
||||
\`8.\`888b ,8' ${"-".repeat(head.length)}
|
||||
\`8.\`888b ,8' OS: WebOS
|
||||
\`8.\`888b .b ,8' Kernel: Wkernel 1.0
|
||||
\`8.\`888b 88b ,8' Shell: Wsh
|
||||
\`8.\`888b .\`888b,8' Terminal: HTML
|
||||
\`8.\`888b8.\`8888' CPU: ${SITE_NAME[0].toUpperCase()}${SITE_NAME.slice(
|
||||
1
|
||||
)} web cpu (1) @ 1GHz
|
||||
\`8.\`888\`8.\`88' Memory: 2 B / 8B
|
||||
\`8.\`8' \`8,\`' Init: WebRC
|
||||
\`8.\` \`8' Packages: ${
|
||||
document.scripts.length + document.styleSheets.length + 1
|
||||
} (document)`,
|
||||
];
|
||||
}
|
||||
|
||||
function cmd_rand() {
|
||||
return ["" + Math.random() * 11e10];
|
||||
}
|
||||
|
||||
function cmd_date() {
|
||||
return new Date().toString();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@ function sleep(ms) {
|
|||
}
|
||||
|
||||
async function evaluate_command(command, output, hist, term_wrap) {
|
||||
let cmd = await command.split(" ");
|
||||
let cmd = await command.split(/ (.+)/);
|
||||
if (cmd.lnegth >= 3) await cmd.pop();
|
||||
|
||||
let cmd_fn = window[`cmd_${cmd[0]}`];
|
||||
|
||||
if (!cmd_fn) {
|
||||
|
@ -21,7 +23,11 @@ async function evaluate_command(command, output, hist, term_wrap) {
|
|||
return;
|
||||
}
|
||||
|
||||
for (let elem of await cmd_fn(cmd.slice(1), hist, term_wrap)) {
|
||||
for (let elem of await cmd_fn(
|
||||
cmd.length > 1 ? cmd[1] : "",
|
||||
hist,
|
||||
term_wrap
|
||||
)) {
|
||||
switch (elem.constructor) {
|
||||
case String:
|
||||
for (let c of elem) {
|
||||
|
|
Loading…
Add table
Reference in a new issue