36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import * as plugins from '../../../plugins.js';
|
|
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
|
import type { IProcessConfig } from '../../../shared/protocol/ipc.types.js';
|
|
import type { CliArguments } from '../../types.js';
|
|
import { parseMemoryString, formatMemory } from '../../helpers/memory.js';
|
|
import { registerIpcCommand } from '../../registration/index.js';
|
|
|
|
export function registerStartCommand(smartcli: plugins.smartcli.Smartcli) {
|
|
registerIpcCommand(
|
|
smartcli,
|
|
'start',
|
|
async (argvArg: CliArguments) => {
|
|
const id = argvArg._[1];
|
|
if (!id) {
|
|
console.error('Error: Please provide a process ID to start');
|
|
console.log('Usage: tspm start <id>');
|
|
return;
|
|
}
|
|
|
|
const desc = await tspmIpcClient.request('describe', { id }).catch(() => null);
|
|
if (!desc) {
|
|
console.error(`Process with id '${id}' not found. Use 'tspm add' first.`);
|
|
return;
|
|
}
|
|
|
|
console.log(`Starting process id ${id} (${desc.config.name || id})...`);
|
|
const response = await tspmIpcClient.request('start', { config: desc.config });
|
|
console.log('✓ Process started');
|
|
console.log(` ID: ${response.processId}`);
|
|
console.log(` PID: ${response.pid || 'N/A'}`);
|
|
console.log(` Status: ${response.status}`);
|
|
},
|
|
{ actionLabel: 'start process' },
|
|
);
|
|
}
|