MCPcopy Create free account
hub / github.com/msgbyte/tailchat / handler

Function handler

apps/cli/src/commands/usage.ts:15–51  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

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};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected