26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import * as plugins from '../../../plugins.js';
|
|
import { tspmIpcClient } from '../../../classes.ipcclient.js';
|
|
import type { CliArguments } from '../../types.js';
|
|
import { registerIpcCommand } from '../../registration/index.js';
|
|
|
|
export function registerStopAllCommand(smartcli: plugins.smartcli.Smartcli) {
|
|
registerIpcCommand(smartcli, 'stop-all', async (_argvArg: CliArguments) => {
|
|
console.log('Stopping all processes...');
|
|
const response = await tspmIpcClient.request('stopAll', {});
|
|
|
|
if (response.stopped.length > 0) {
|
|
console.log(`✓ Stopped ${response.stopped.length} processes:`);
|
|
for (const id of response.stopped) {
|
|
console.log(` - ${id}`);
|
|
}
|
|
}
|
|
|
|
if (response.failed.length > 0) {
|
|
console.log(`✗ Failed to stop ${response.failed.length} processes:`);
|
|
for (const failure of response.failed) {
|
|
console.log(` - ${failure.id}: ${failure.error}`);
|
|
}
|
|
process.exitCode = 1; // Signal partial failure
|
|
}
|
|
}, { actionLabel: 'stop all processes' });
|
|
} |