add cmd list

This commit is contained in:
b1ek 2023-03-15 16:23:05 +10:00
parent a326c8f6b8
commit 2528c0e356
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,25 @@
import { Terminal } from 'xterm';
/**
*
* @param {string[]} argv
* @param {Terminal} terminal
*/
module.exports = (argv, terminal) => {
if (argv.indexOf('--help') != -1) {
terminal.writeln(`Usage: ${argv[0]} [--help]`);
terminal.writeln('Lists all available commands.');
return;
}
const cmds = Object.keys(require('../commands'));
let i = 0;
cmds.forEach(x => {
if (x == argv[0]) return;
if (i == 4) {
terminal.writeln('');
i = 0;
} else i++;
terminal.write('\033[1;32m' + x + '\033[0m ');
});
terminal.writeln('');
}

View File

@ -1,5 +1,8 @@
let cmds = {
'cat': require('./cat')
'cat': require('./cat'),
'cmds': require('./cmds'),
'cmdls': require('./cmds'),
'help': require('./cmds')
};
module.exports = cmds;