// Package mode detects whether the CLI runs in padded-cell mode or manual mode. package mode import ( "os/exec" "sync" ) // RuntimeMode represents the CLI operating mode. type RuntimeMode int const ( // ManualMode requires explicit --token / --acc-mgr-token flags. ManualMode RuntimeMode = iota // PaddedCellMode resolves secrets via pass_mgr automatically. PaddedCellMode ) var ( detectedMode RuntimeMode detectOnce sync.Once ) // Detect checks whether pass_mgr is available and returns the runtime mode. // The result is cached after the first call. func Detect() RuntimeMode { detectOnce.Do(func() { _, err := exec.LookPath("pass_mgr") if err == nil { detectedMode = PaddedCellMode } else { detectedMode = ManualMode } }) return detectedMode } // IsPaddedCell is a convenience helper. func IsPaddedCell() bool { return Detect() == PaddedCellMode } // String returns a human-readable mode name. func (m RuntimeMode) String() string { switch m { case PaddedCellMode: return "padded-cell" case ManualMode: return "manual" default: return "unknown" } }