improve ps

This commit is contained in:
b1ek 2023-05-04 23:44:10 +10:00
parent ee68c78021
commit cf04d4da15
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 10 additions and 5 deletions

View File

@ -1,20 +1,24 @@
const { Terminal } = require("xterm");
const sleep = require('../../lib/sleep');
/**
*
* @param {string[]} argv
* @param {Terminal} terminal
*/
module.exports = (argv, terminal) => {
module.exports = async (argv, terminal) => {
if (argv.indexOf('--help') != -1) {
terminal.write(
`Usage: ${argv[0]} [OPTIONS]
Show current process list`);
return;
}
terminal.write(
`\tPID\tTTY\tTIME\tCMD
42\tpts/0\t00:00:00\tzsh
43\tpts/0\t00:00:00\tps
terminal.write('PID\tTTY\tTIME\t\tCMD');
await sleep(5);
terminal.write(`
1\tpts/0\t00:00:00\tzsh
2\tpts/0\t00:00:00\tps
`);
}

1
src/lib/sleep.js Normal file
View File

@ -0,0 +1 @@
module.exports = (timeout) => new Promise(r => setTimeout(r, timeout));