mirror of
https://github.com/sbrow/envr.git
synced 2025-12-29 23:47:39 -05:00
refactor: Rewrote in golang.
This commit is contained in:
32
app/features.go
Normal file
32
app/features.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// Represents which binaries are present in $PATH.
|
||||
// Used to fail safely when required features are unavailable
|
||||
type AvailableFeatures int
|
||||
|
||||
const (
|
||||
Git AvailableFeatures = 1
|
||||
// fd
|
||||
Fd AvailableFeatures = 2
|
||||
// All features are present
|
||||
All AvailableFeatures = Git & Fd
|
||||
)
|
||||
|
||||
// Checks for available features.
|
||||
func checkFeatures() (feats AvailableFeatures) {
|
||||
// Check for git binary
|
||||
if _, err := exec.LookPath("git"); err == nil {
|
||||
feats |= Git
|
||||
}
|
||||
|
||||
// Check for fd binary
|
||||
if _, err := exec.LookPath("fd"); err == nil {
|
||||
feats |= Fd
|
||||
}
|
||||
|
||||
return feats
|
||||
}
|
||||
Reference in New Issue
Block a user