mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 15:32:53 +00:00
19 lines
499 B
Go
19 lines
499 B
Go
package conditions
|
|
|
|
import (
|
|
"github.com/rsteube/carapace"
|
|
"github.com/rsteube/carapace-bin/internal/condition"
|
|
"github.com/rsteube/carapace/pkg/traverse"
|
|
)
|
|
|
|
// ConditionParent checks if any parent directory contains one of the given file/directory
|
|
//
|
|
// ConditionParent(".git")
|
|
// ConditionParent("go.mod", "go.sum")
|
|
func ConditionParent(s ...string) condition.Condition {
|
|
return func(c carapace.Context) bool {
|
|
_, err := traverse.Parent(s...)(carapace.NewContext())
|
|
return err == nil
|
|
}
|
|
}
|