-
Notifications
You must be signed in to change notification settings - Fork 0
Add daemon reinstall command #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
|
Comment on lines
+14
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By calling This can be confusing. For a better user experience, only the final 'reinstalled' message should be shown. A long-term solution would be to refactor the core logic of |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
reinstallcommand should perform its own root check. Currently, it relies on theuninstallandinstallsub-commands to do this. This can lead to confusing error messages for the user (e.g.,sudo shelltime daemon uninstallrequired, when they ranreinstall).By adding an explicit root check to
commandDaemonReinstall, you provide a clearer error message and make the command's preconditions explicit. This also avoids the redundant root check that would happen in both the uninstall and install steps.