Files
tspm/ts/cli/commands/process/delete.ts

33 lines
1.3 KiB
TypeScript

import * as plugins from '../../../plugins.js';
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
import type { CliArguments } from '../../types.js';
import { registerIpcCommand } from '../../registration/index.js';
export function registerDeleteCommand(smartcli: plugins.smartcli.Smartcli) {
registerIpcCommand(
smartcli,
['delete', 'remove'],
async (argvArg: CliArguments) => {
const id = argvArg._[1];
if (!id) {
console.error('Error: Please provide a process ID');
console.log('Usage: tspm delete <id> | tspm remove <id>');
return;
}
// Determine if command was 'remove' to use the new IPC route, otherwise 'delete'
const cmd = String(argvArg._[0]);
const useRemove = cmd === 'remove';
console.log(`${useRemove ? 'Removing' : 'Deleting'} process: ${id}`);
const response = await tspmIpcClient.request(useRemove ? 'remove' : 'delete', { id } as any);
if (response.success) {
console.log(`${response.message || (useRemove ? 'Removed successfully' : 'Deleted successfully')}`);
} else {
console.error(`✗ Failed to ${useRemove ? 'remove' : 'delete'} process: ${response.message}`);
}
},
{ actionLabel: 'delete/remove process' },
);
}