Files
tspm/ts/cli/commands/reset.ts

34 lines
1.2 KiB
TypeScript

import * as plugins from '../plugins.js';
import { registerIpcCommand } from '../registration/index.js';
import { tspmIpcClient } from '../../client/tspm.ipcclient.js';
export function registerResetCommand(smartcli: plugins.smartcli.Smartcli) {
registerIpcCommand(
smartcli,
'reset',
async () => {
console.log('This will stop all processes and clear saved configurations.');
const confirmed = await plugins.smartinteract.SmartInteract.getCliConfirmation(
'Are you sure you want to reset TSPM? (stops all and removes configs)',
false,
);
if (!confirmed) {
console.log('Reset cancelled. No changes made.');
return;
}
// Single IPC call to reset
const result = await tspmIpcClient.request('reset', {});
const failedCount = result.failed.length;
console.log(`Stopped ${result.stopped.length} processes.`);
if (failedCount) {
console.log(`${failedCount} processes failed to stop (configs cleared anyway).`);
}
console.log(`Cleared ${result.removed.length} saved configurations.`);
console.log('TSPM has been reset.');
},
{ actionLabel: 'reset TSPM' },
);
}