Trim flags to avoid mistakes due to empty lines or espaces...

This commit is contained in:
nemunaire 2021-12-07 16:33:30 +01:00
commit 0cc72712a4
7 changed files with 24 additions and 14 deletions

View file

@ -38,6 +38,7 @@ type ExerciceFlag struct {
ShowLines bool `toml:",omitempty"`
Ordered bool `toml:",omitempty"`
CaseSensitive bool `toml:",omitempty"`
NoTrim bool `toml:",omitempty"`
ValidatorRe string `toml:"validator_regexp,omitempty"`
Placeholder string `toml:",omitempty"`
Help string `toml:",omitempty"`

View file

@ -124,7 +124,7 @@ func buildKeyFlag(exercice *fic.Exercice, flag ExerciceFlag, flagline int, defau
errs = append(errs, fmt.Sprintf("%q: WARNING flag #%d: non-printable characters in flag, is this really expected?", path.Base(exercice.Path), flagline))
}
hashedFlag, err := fic.ComputeHashedFlag([]byte(raw), !flag.CaseSensitive, validatorRegexp(flag.ValidatorRe))
hashedFlag, err := fic.ComputeHashedFlag([]byte(raw), !flag.CaseSensitive, flag.NoTrim, validatorRegexp(flag.ValidatorRe))
if err != nil {
errs = append(errs, fmt.Sprintf("%q: flag #%d: %s", path.Base(exercice.Path), flagline, err.Error()))
return