From 27384d03c752b9500a64f38c09afe0e6519a1b88 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Fri, 29 Aug 2025 12:16:43 +0000 Subject: [PATCH] feat(cli): Add support for restarting all processes from CLI; improve usage message and reporting --- changelog.md | 7 +++++++ ts/00_commitinfo_data.ts | 2 +- ts/cli/commands/process/restart.ts | 26 ++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 60968a0..e109f88 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # 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) Add persistent process registration (tspm add), alias remove, and change start to use saved process IDs (breaking CLI behavior) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 61cf220..85d1461 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tspm', - version: '4.0.0', + version: '4.1.0', description: 'a no fuzz process manager' } diff --git a/ts/cli/commands/process/restart.ts b/ts/cli/commands/process/restart.ts index 8719071..6b1703d 100644 --- a/ts/cli/commands/process/restart.ts +++ b/ts/cli/commands/process/restart.ts @@ -8,13 +8,31 @@ export function registerRestartCommand(smartcli: plugins.smartcli.Smartcli) { smartcli, 'restart', async (argvArg: CliArguments) => { - const id = argvArg._[1]; - if (!id) { - console.error('Error: Please provide a process ID'); - console.log('Usage: tspm restart '); + const arg = argvArg._[1]; + if (!arg) { + console.error('Error: Please provide a process ID or "all"'); + console.log('Usage:'); + console.log(' tspm restart '); + console.log(' tspm restart all'); 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}`); const response = await tspmIpcClient.request('restart', { id });