feat(sync): envr can now detect if directories have moved.

This commit is contained in:
2025-11-10 10:04:46 -05:00
committed by Spencer Brower
parent 638751fb48
commit 4db0a4d33d
8 changed files with 186 additions and 30 deletions

View File

@@ -1,9 +1,20 @@
package app
import (
"fmt"
"os/exec"
)
type MissingFeatureError struct {
feature AvailableFeatures
}
func (m *MissingFeatureError) Error() string {
return fmt.Sprintf("Missing \"%s\" feature", m.feature)
}
// TODO: Features should really be renamed to Binaries
// Represents which binaries are present in $PATH.
// Used to fail safely when required features are unavailable
type AvailableFeatures int
@@ -30,3 +41,20 @@ func checkFeatures() (feats AvailableFeatures) {
return feats
}
// Returns a MissingFeature error if the given features aren't present.
func (a AvailableFeatures) validateFeatures(features ...AvailableFeatures) error {
var missing AvailableFeatures
for _, feat := range features {
if a&feat == 0 {
missing |= feat
}
}
if missing == 0 {
return nil
} else {
return &MissingFeatureError{missing}
}
}