Files
simslim-mirror/output.go
Interlap a4a9c30b0d feat: add doctor command to verify required features after slimming
`simslim doctor <udid> --requires push,storekit,universal-links` checks a
booted simulator against a list of required feature IDs and exits non-zero if
slimming has disabled any of their backing daemons — a fast CI preflight that
aborts before a suite runs against a simulator slimmed too aggressively for it.

- features.go: a Features catalog, finer-grained than Categories — each feature
  names just the daemons one capability needs. resolveFeatures errors loudly on
  unknown IDs; diagnoseFeatures is pure and reports which daemons are down.
- doctor supports --json and --list (enumerate every checkable feature).
- features_test.go asserts every feature label is slimmable, so the catalog
  stays in sync with Categories.

Implements #4.
2026-07-22 22:32:07 +02:00

69 lines
2.2 KiB
Go

package main
import (
"encoding/json"
"os"
)
// DeviceSummary is the stable, machine-readable representation used by the
// macOS app and other integrations. managedDisabled is omitted for shutdown
// simulators because launchd state can only be read while a simulator is booted.
type DeviceSummary struct {
Device
ManagedDisabled *int `json:"managedDisabled,omitempty"`
ManagedTotal int `json:"managedTotal"`
StatusError string `json:"statusError,omitempty"`
Memory *Measurement `json:"memory,omitempty"`
MemoryError string `json:"memoryError,omitempty"`
}
type StatusOutput struct {
Status
Verdict string `json:"verdict"`
Dropped []DroppedCategory `json:"dropped,omitempty"` // only when `status --dropped` is requested
}
// DroppedCategory lists the managed daemons a category has disabled on a
// simulator, alongside the feature that stops working as a result.
type DroppedCategory struct {
ID string `json:"id"`
Name string `json:"name"`
Downside string `json:"downside"`
Labels []string `json:"labels"`
}
// SimulatorMutationOutput is returned by simulator-management commands so the
// GUI can refresh and, for clone, select the newly created device.
type SimulatorMutationOutput struct {
Action string `json:"action"`
UDID string `json:"udid"`
Name string `json:"name,omitempty"`
SourceUDID string `json:"sourceUdid,omitempty"`
}
// DoctorOutput reports whether each required feature survives the device's
// current slimming. OK is false when any required feature has a disabled daemon.
type DoctorOutput struct {
UDID string `json:"udid,omitempty"`
OK bool `json:"ok"`
Features []FeatureStatus `json:"features"`
}
// FeatureStatus is one feature's verdict: the daemons it needs that are down.
type FeatureStatus struct {
ID string `json:"id"`
Name string `json:"name"`
OK bool `json:"ok"`
Disabled []string `json:"disabled,omitempty"`
}
type DiskMeasurement struct {
Bytes int64 `json:"bytes"`
}
func writeJSON(value any) error {
encoder := json.NewEncoder(os.Stdout)
encoder.SetIndent("", " ")
return encoder.Encode(value)
}