build: remove directive text not applied on build.

This commit is contained in:
Alexandre Pujol 2024-04-28 14:22:00 +01:00
parent 2aa8986a21
commit c7fb47e97a
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
3 changed files with 11 additions and 4 deletions

View file

@ -61,6 +61,13 @@ func NewOption(file *paths.Path, match []string) *Option {
}
}
// Clean the selected directive from profile.
// Useful to remove directive text applied on some condition only
func (o *Option) Clean(profile string) string {
reg := regexp.MustCompile(`\s*` + Keyword + o.Name + ` .*$`)
return reg.ReplaceAllString(profile, "")
}
func RegisterDirective(d Directive) {
Directives[d.Name()] = d
}