52 lines
1022 B
TypeScript
52 lines
1022 B
TypeScript
import { Menu } from './menu/menu';
|
|
import { MenuType } from './menu/interface';
|
|
|
|
class Main {
|
|
private readonly _menu = [
|
|
{
|
|
display: "df -h",
|
|
type: MenuType.ExecCommand,
|
|
command: ["df", "-h"],
|
|
},
|
|
{
|
|
display: "Games",
|
|
type: MenuType.SubMenu,
|
|
subMenu: [
|
|
{
|
|
display: "Chess",
|
|
type: MenuType.ExecCommand,
|
|
command: ["df", "-h"],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
display: "Reboot",
|
|
type: MenuType.Reboot,
|
|
},
|
|
{
|
|
display: "Shutdown",
|
|
type: MenuType.Shutdown,
|
|
},
|
|
];
|
|
|
|
public async runAsync(): Promise<void> {
|
|
while (true) {
|
|
const selected = await new Menu(this._menu, process.env['CONSOLE'] === '1').getSelection();
|
|
switch(selected.type) {
|
|
case MenuType.Shutdown:
|
|
process.exit();
|
|
case MenuType.Reboot:
|
|
process.exit();
|
|
case MenuType.ExecCommand:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async function run() {
|
|
await new Main().runAsync();
|
|
}
|
|
|
|
run();
|