mirror of
https://github.com/sbrow/envr.git
synced 2025-12-29 23:47:39 -05:00
feat(sync): envr can now detect if directories have moved.
This commit is contained in:
@@ -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}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user