The secret manager binary was renamed from pass_mgr to secret-mgr. Update all references in CLI code, mode detection, and help text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
// 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 secret-mgr automatically.
|
|
PaddedCellMode
|
|
)
|
|
|
|
var (
|
|
detectedMode RuntimeMode
|
|
detectOnce sync.Once
|
|
)
|
|
|
|
// Detect checks whether secret-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("secret-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"
|
|
}
|
|
}
|