Skip to content

Commit eb15c2e

Browse files
Add daemon reinstall command
- Added DaemonReinstallCommand that calls uninstall followed by install - Updated daemon.go to include the new reinstall subcommand - Addresses issue #97 Co-authored-by: Le He <AnnatarHe@users.noreply.github.com>
1 parent cf1041f commit eb15c2e

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

commands/daemon.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ var DaemonCommand *cli.Command = &cli.Command{
88
Subcommands: []*cli.Command{
99
DaemonInstallCommand,
1010
DaemonUninstallCommand,
11+
DaemonReinstallCommand,
1112
},
1213
}

commands/daemon.reinstall.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package commands
2+
3+
import (
4+
"github.com/gookit/color"
5+
"github.com/urfave/cli/v2"
6+
)
7+
8+
var DaemonReinstallCommand = &cli.Command{
9+
Name: "reinstall",
10+
Usage: "Reinstall the shelltime daemon service (uninstall then install)",
11+
Action: commandDaemonReinstall,
12+
}
13+
14+
func commandDaemonReinstall(c *cli.Context) error {
15+
color.Yellow.Println("🔄 Starting daemon service reinstallation...")
16+
17+
// First, uninstall the existing service
18+
color.Yellow.Println("🗑 Uninstalling existing daemon service...")
19+
if err := commandDaemonUninstall(c); err != nil {
20+
return err
21+
}
22+
23+
// Then, install the service
24+
color.Yellow.Println("📦 Installing daemon service...")
25+
if err := commandDaemonInstall(c); err != nil {
26+
return err
27+
}
28+
29+
color.Green.Println("✅ Daemon service has been successfully reinstalled!")
30+
return nil
31+
}

0 commit comments

Comments
 (0)