Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ shelltime codex install
| `shelltime hooks uninstall` | Remove shell hooks |
| `shelltime daemon install` | Install the ShellTime daemon service |
| `shelltime daemon status` | Check daemon status |
| `shelltime daemon reinstall` | Reinstall the daemon service |
| `shelltime daemon reinstall` | Reinstall and restart the daemon service (alias: `shelltime daemon restart`) |
| `shelltime daemon uninstall` | Remove the daemon service |
| `shelltime alias import` | Import aliases from `~/.zshrc` and `~/.config/fish/config.fish` (`--full` re-imports everything) |
| `shelltime config view` | Show the merged current configuration (`--format json`) |
Expand Down
11 changes: 8 additions & 3 deletions commands/daemon.reinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import (
"github.com/urfave/cli/v2"
)

// DaemonReinstallCommand is also `daemon restart`, the name people reach for
// after a config change. It stays a full reinstall rather than a plain service
// restart: rewriting the service definition is what points it at the current
// binary after an update or a move between Homebrew and the curl installer.
var DaemonReinstallCommand = &cli.Command{
Name: "reinstall",
Usage: "Reinstall the shelltime daemon service (uninstall then install)",
Action: commandDaemonReinstall,
Name: "reinstall",
Aliases: []string{"restart"},
Usage: "Reinstall and restart the shelltime daemon service (uninstall then install)",
Action: commandDaemonReinstall,
}

func commandDaemonReinstall(c *cli.Context) error {
Expand Down
22 changes: 22 additions & 0 deletions commands/daemon.reinstall_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package commands

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/urfave/cli/v2"
)

func TestDaemonRestartIsReinstall(t *testing.T) {
for _, name := range []string{"reinstall", "restart"} {
var matches []*cli.Command
for _, sub := range DaemonCommand.Subcommands {
if sub.HasName(name) {
matches = append(matches, sub)
}
}
if assert.Len(t, matches, 1, "daemon %s", name) {
assert.Same(t, DaemonReinstallCommand, matches[0], "daemon %s", name)
}
}
}
Loading