glob101/router/explain.go
John Olheiser 67650ce6c1 Real router and real assets (#4)
Fix imports and change CLI colors

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Real router and real assets

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Reviewed-on: #4
2020-01-31 03:59:55 +00:00

38 lines
775 B
Go

package router
import "gitea.com/jolheiser/globber"
type explanation struct {
Includes []string `json:"includes"`
Excludes []string `json:"excludes"`
}
type match struct {
Line int `json:"line"`
Length int `json:"length"`
Include bool `json:"include"`
Explanation explanation `json:"explanation"`
}
type response struct {
Matches []match `json:"matches"`
Error error `json:"error"`
}
func explain(includes, excludes []globber.Globber) explanation {
expin := make([]string, 0)
for _, inc := range includes {
expin = append(expin, inc.Pattern)
}
expex := make([]string, 0)
for _, exp := range excludes {
expex = append(expex, "!"+exp.Pattern)
}
return explanation{
Includes: expin,
Excludes: expex,
}
}