55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"srs.epita.fr/fic-server/admin/sync"
|
|
"srs.epita.fr/fic-server/libfic"
|
|
)
|
|
|
|
func GrammalecteCheckKeyFlag(flag *fic.FlagKey, raw string, exceptions *sync.CheckExceptions) (errs []error) {
|
|
label, _, _, _ := flag.AnalyzeFlagLabel()
|
|
for _, err := range grammalecte("label ", label, exceptions, &CommonOpts) {
|
|
if e, ok := err.(GrammarError); ok && e.RuleId == "poncfin_règle1" {
|
|
continue
|
|
}
|
|
|
|
errs = append(errs, err)
|
|
}
|
|
|
|
if len(flag.Help) > 0 {
|
|
errs = append(errs, grammalecte("help ", flag.Help, exceptions, &CommonOpts)...)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func GrammalecteCheckFlagChoice(choice *fic.FlagChoice, exceptions *sync.CheckExceptions) (errs []error) {
|
|
errs = append(errs, grammalecte("label ", choice.Label, exceptions, &CommonOpts)...)
|
|
|
|
return
|
|
}
|
|
|
|
func GrammalecteCheckHint(hint *fic.EHint, exceptions *sync.CheckExceptions) (errs []error) {
|
|
if len(hint.Title) > 0 {
|
|
errs = append(errs, grammalecte("title ", hint.Title, exceptions, &CommonOpts)...)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func GrammalecteCheckMDText(str string, exceptions *sync.CheckExceptions) (errs []error) {
|
|
errs = append(errs, grammalecte("", str, exceptions, &CommonOpts)...)
|
|
|
|
return
|
|
}
|
|
|
|
func GrammalecteCheckGrammar(data interface{}, exceptions *sync.CheckExceptions) (errs []error) {
|
|
if s, ok := data.(string); ok {
|
|
return grammalecte("", s, exceptions, &CommonOpts)
|
|
} else {
|
|
log.Printf("Unknown data given to GrammalecteCheckGrammar: %T", data)
|
|
return nil
|
|
}
|
|
}
|