diff --git a/README.md b/README.md index 2978a4f..a8c0216 100644 --- a/README.md +++ b/README.md @@ -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`) | diff --git a/commands/daemon.reinstall.go b/commands/daemon.reinstall.go index 60b84fb..7e3cd12 100644 --- a/commands/daemon.reinstall.go +++ b/commands/daemon.reinstall.go @@ -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 { diff --git a/commands/daemon.reinstall_test.go b/commands/daemon.reinstall_test.go new file mode 100644 index 0000000..96f0a8c --- /dev/null +++ b/commands/daemon.reinstall_test.go @@ -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) + } + } +}