add systemctl, exit and echo commands

This commit is contained in:
b1ek 2023-03-23 10:09:58 +10:00
parent 8f56141c17
commit ef960d6f6f
Signed by: blek
GPG Key ID: 14546221E3595D0C
4 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,36 @@
const { Terminal } = require("xterm");
/**
*
* @param {string[]} argv
* @param {Terminal} terminal
*/
module.exports = (argv, terminal) => {
if (argv.indexOf('--help') != -1) {
terminal.write(
`Usage: ${argv[0]} [-e] [MESSAGE]
Print a line of text into terminal.
-e \t Enable parsing of backslash escapes`
);
return;
}
let args = [...argv];
args.shift();
// remove -e
if (args.indexOf('-e') != -1)
args.splice(args.indexOf('-e'), 1)
let text = args.join(' ');
if (argv.indexOf('-e') != -1) {
try {
text = JSON.parse(`"${text}"`);
} catch (err) {
terminal.write(`${argv[0]}: can't parse string: ${err}`);
}
}
terminal.writeln(text);
}

View File

@ -0,0 +1,10 @@
const { Terminal } = require("xterm");
/**
*
* @param {string[]} argv
* @param {Terminal} terminal
*/
module.exports = (argv, terminal) => {
terminal.writeln(`${argv[0]}: not supported`);
}

View File

@ -12,6 +12,9 @@ let cmds = {
'ps': require('./ps'),
'clear': require('./clear'),
'rm': require('./rm'),
'echo': require('./echo'),
'exit': require('./exit'),
'systemctl': require('./systemctl'),
'guide': require('./guide'),

View File

@ -0,0 +1,10 @@
const { Terminal } = require("xterm");
/**
*
* @param {string[]} argv
* @param {Terminal} terminal
*/
module.exports = (argv, terminal) => {
terminal.writeln(`${argv[0]}: systemd is bad`);
}