From 720f1957ca1e1b497ae7fb9ffb55de25c0f13241 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Mon, 8 Sep 2025 07:53:44 +0000 Subject: [PATCH] feat: add daemon reinstall command Adds daemon reinstall command support that calls uninstall and install - Added DaemonReinstallCommand in new file commands/daemon.reinstall.go - Updated commands/daemon.go to include the reinstall subcommand - Command calls existing uninstall then install functions - Includes proper error handling and user feedback Fixes #97 Co-authored-by: Le He --- commands/daemon.go | 1 + commands/daemon.reinstall.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 commands/daemon.reinstall.go diff --git a/commands/daemon.go b/commands/daemon.go index 41b3c60..dbf49cc 100644 --- a/commands/daemon.go +++ b/commands/daemon.go @@ -8,5 +8,6 @@ var DaemonCommand *cli.Command = &cli.Command{ Subcommands: []*cli.Command{ DaemonInstallCommand, DaemonUninstallCommand, + DaemonReinstallCommand, }, } diff --git a/commands/daemon.reinstall.go b/commands/daemon.reinstall.go new file mode 100644 index 0000000..3a5cbc7 --- /dev/null +++ b/commands/daemon.reinstall.go @@ -0,0 +1,31 @@ +package commands + +import ( + "github.com/gookit/color" + "github.com/urfave/cli/v2" +) + +var DaemonReinstallCommand = &cli.Command{ + Name: "reinstall", + Usage: "Reinstall the shelltime daemon service (uninstall then install)", + Action: commandDaemonReinstall, +} + +func commandDaemonReinstall(c *cli.Context) error { + color.Yellow.Println("🔄 Starting daemon service reinstallation...") + + // First, uninstall the existing service + color.Yellow.Println("🗑 Uninstalling existing daemon service...") + if err := commandDaemonUninstall(c); err != nil { + return err + } + + // Then, install the service + color.Yellow.Println("📦 Installing daemon service...") + if err := commandDaemonInstall(c); err != nil { + return err + } + + color.Green.Println("✅ Daemon service has been successfully reinstalled!") + return nil +} \ No newline at end of file