feat(cli): Add support for restarting all processes from CLI; improve usage message and reporting

This commit is contained in:
2025-08-29 12:16:43 +00:00
parent 47afd4739a
commit 27384d03c7
3 changed files with 30 additions and 5 deletions

View File

@@ -1,5 +1,12 @@
# Changelog # Changelog
## 2025-08-29 - 4.1.0 - feat(cli)
Add support for restarting all processes from CLI; improve usage message and reporting
- CLI 'restart' command now accepts 'all' to restart all processes via the daemon (tspm restart all).
- Improved usage/help output when no process id is provided.
- CLI now prints summaries of restarted process IDs and failed restarts and sets a non-zero exit code when any restarts failed.
## 2025-08-29 - 4.0.0 - BREAKING CHANGE(cli) ## 2025-08-29 - 4.0.0 - BREAKING CHANGE(cli)
Add persistent process registration (tspm add), alias remove, and change start to use saved process IDs (breaking CLI behavior) Add persistent process registration (tspm add), alias remove, and change start to use saved process IDs (breaking CLI behavior)

View File

@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@git.zone/tspm', name: '@git.zone/tspm',
version: '4.0.0', version: '4.1.0',
description: 'a no fuzz process manager' description: 'a no fuzz process manager'
} }

View File

@@ -8,13 +8,31 @@ export function registerRestartCommand(smartcli: plugins.smartcli.Smartcli) {
smartcli, smartcli,
'restart', 'restart',
async (argvArg: CliArguments) => { async (argvArg: CliArguments) => {
const id = argvArg._[1]; const arg = argvArg._[1];
if (!id) { if (!arg) {
console.error('Error: Please provide a process ID'); console.error('Error: Please provide a process ID or "all"');
console.log('Usage: tspm restart <id>'); console.log('Usage:');
console.log(' tspm restart <id>');
console.log(' tspm restart all');
return; return;
} }
if (String(arg).toLowerCase() === 'all') {
console.log('Restarting all processes...');
const res = await tspmIpcClient.request('restartAll', {});
if (res.restarted.length > 0) {
console.log(`✓ Restarted ${res.restarted.length} processes:`);
for (const id of res.restarted) console.log(` - ${id}`);
}
if (res.failed.length > 0) {
console.log(`✗ Failed to restart ${res.failed.length} processes:`);
for (const f of res.failed) console.log(` - ${f.id}: ${f.error}`);
process.exitCode = 1;
}
return;
}
const id = String(arg);
console.log(`Restarting process: ${id}`); console.log(`Restarting process: ${id}`);
const response = await tspmIpcClient.request('restart', { id }); const response = await tspmIpcClient.request('restart', { id });