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 @@ -72,7 +72,7 @@ shelltime codex install
| `shelltime init` | Bootstrap auth, hooks, daemon, and AI-code integrations |
| `shelltime auth` | Authenticate with `shelltime.xyz` |
| `shelltime update` | Download and install the latest release in place |
| `shelltime doctor` | Check installation and environment health |
| `shelltime doctor` | Diagnose setup problems and show how to fix each one (`--fix` applies the safe fixes, `--offline`, `--format json`) |
| `shelltime web` | Open the ShellTime dashboard in a browser |

### Tracking and sync
Expand Down
14 changes: 13 additions & 1 deletion cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"fmt"
"log/slog"
"os"
Expand All @@ -22,6 +23,11 @@ var (
)

func main() {
os.Exit(run())
}

// run holds main's body so its deferred cleanup finishes before main sets the exit code.
func run() int {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
cli.VersionFlag = &cli.BoolFlag{
Expand Down Expand Up @@ -113,8 +119,14 @@ func main() {
commands.UpdateCommand,
}
err = app.Run(os.Args)
if err != nil {
// doctor already reported its problems; it only needs a non-zero exit code.
doctorFailed := errors.Is(err, commands.ErrDoctorFoundProblems)
if err != nil && !doctorFailed {
slog.Error("CLI error", slog.Any("err", err))
}
commands.CloseLogger()
if doctorFailed {
return 1
}
return 0
}
4 changes: 4 additions & 0 deletions commands/daemon.status.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func requestDaemonStatus(socketPath string, timeout time.Duration) (*daemon.Stat
return nil, 0, err
}
defer conn.Close()
// Bound the whole exchange: a socket file whose owner never answers would otherwise block.
if err := conn.SetDeadline(start.Add(timeout)); err != nil {
return nil, 0, err
}

// Send status request
msg := daemon.SocketMessage{
Expand Down
Loading
Loading