(args)
| 13 | type: 'number', |
| 14 | }), |
| 15 | async handler(args) { |
| 16 | let pidList: number[] = []; |
| 17 | |
| 18 | if (!args.pid) { |
| 19 | const list = await find('name', 'tailchat'); |
| 20 | |
| 21 | const processList = list.filter((item) => item.pid !== process.pid); |
| 22 | |
| 23 | const res = await inquirer.prompt([ |
| 24 | { |
| 25 | type: 'checkbox', |
| 26 | name: 'process', |
| 27 | message: 'Select the process to view', |
| 28 | choices: processList.map((item) => ({ |
| 29 | name: `(${item.pid})${item.cmd}`, |
| 30 | value: item.pid, |
| 31 | })), |
| 32 | }, |
| 33 | ]); |
| 34 | |
| 35 | pidList = res.process; |
| 36 | } else { |
| 37 | if (Array.isArray(args.pid)) { |
| 38 | pidList = args.pid; |
| 39 | } else { |
| 40 | pidList = [args.pid as number]; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | const stats = await pidusage(pidList); |
| 45 | const res = Object.entries(stats).map(([pid, info]) => ({ |
| 46 | pid, |
| 47 | cpu: info.cpu, |
| 48 | memory: `${info.memory / 1024 / 1024} MB`, |
| 49 | })); |
| 50 | console.table(res); |
| 51 | }, |
| 52 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected