Add exit command (fix #3)

This commit is contained in:
2021-12-26 14:07:46 +01:00
parent eb49cfdd68
commit 3dea76b80f
2 changed files with 30 additions and 3 deletions

View File

@ -178,4 +178,21 @@ const project: Command = {
}
};
export const commandList = [about, help, man, project];
const exitCmd: Command = {
name: "exit",
desc: "Tries to close this tab. Mostly fails because of restrictions.",
execute: () => {
if (typeof window !== undefined) {
window.opener = null;
window.open('', '_self');
window.close();
}
return [
"If you can read this, closing the window did not work.",
"This is because of restriction in JavaScript.",
"Read more here: https://developer.mozilla.org/en-US/docs/Web/API/Window/close"
]
}
}
export const commandList = [about, help, man, project, exitCmd];