Implement sort_regexp_validator_groups
This commit is contained in:
parent
081ad1f928
commit
5a79343af8
7 changed files with 42 additions and 26 deletions
|
|
@ -399,16 +399,17 @@ func deleteExerciceHint(hint *fic.EHint, _ []byte) (interface{}, error) {
|
|||
}
|
||||
|
||||
type uploadedFlag struct {
|
||||
Type string
|
||||
Label string
|
||||
Placeholder string
|
||||
IgnoreCase bool
|
||||
Multiline bool
|
||||
NoTrim bool
|
||||
ValidatorRe *string `json:"validator_regexp"`
|
||||
Flag string
|
||||
Value []byte
|
||||
ChoicesCost int64 `json:"choices_cost"`
|
||||
Type string
|
||||
Label string
|
||||
Placeholder string
|
||||
IgnoreCase bool
|
||||
Multiline bool
|
||||
NoTrim bool
|
||||
ValidatorRe *string `json:"validator_regexp"`
|
||||
SortReGroups bool `json:"sort_re_grps"`
|
||||
Flag string
|
||||
Value []byte
|
||||
ChoicesCost int64 `json:"choices_cost"`
|
||||
}
|
||||
|
||||
func createExerciceFlag(exercice *fic.Exercice, body []byte) (interface{}, error) {
|
||||
|
|
@ -426,7 +427,7 @@ func createExerciceFlag(exercice *fic.Exercice, body []byte) (interface{}, error
|
|||
vre = uk.ValidatorRe
|
||||
}
|
||||
|
||||
return exercice.AddRawFlagKey(uk.Label, uk.Type, uk.Placeholder, uk.IgnoreCase, uk.NoTrim, uk.Multiline, vre, []byte(uk.Flag), uk.ChoicesCost)
|
||||
return exercice.AddRawFlagKey(uk.Label, uk.Type, uk.Placeholder, uk.IgnoreCase, uk.NoTrim, uk.Multiline, vre, uk.SortReGroups, []byte(uk.Flag), uk.ChoicesCost)
|
||||
}
|
||||
|
||||
func showExerciceFlag(flag *fic.FlagKey, _ *fic.Exercice, body []byte) (interface{}, error) {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ type ExerciceFlag struct {
|
|||
CaseSensitive bool `toml:",omitempty"`
|
||||
NoTrim bool `toml:",omitempty"`
|
||||
ValidatorRe string `toml:"validator_regexp,omitempty"`
|
||||
SortReGroups bool `toml:"sort_validator_regexp_groups,omitempty"`
|
||||
Placeholder string `toml:",omitempty"`
|
||||
Help string `toml:",omitempty"`
|
||||
ChoicesCost int64 `toml:"choices_cost,omitempty"`
|
||||
|
|
|
|||
|
|
@ -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, flag.NoTrim, validatorRegexp(flag.ValidatorRe))
|
||||
hashedFlag, err := fic.ComputeHashedFlag([]byte(raw), !flag.CaseSensitive, flag.NoTrim, validatorRegexp(flag.ValidatorRe), flag.SortReGroups)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: flag #%d: %s", path.Base(exercice.Path), flagline, err.Error()))
|
||||
return
|
||||
|
|
@ -140,6 +140,7 @@ func buildKeyFlag(exercice *fic.Exercice, flag ExerciceFlag, flagline int, defau
|
|||
IgnoreCase: !flag.CaseSensitive,
|
||||
Multiline: flag.Type == "text",
|
||||
ValidatorRegexp: validatorRegexp(flag.ValidatorRe),
|
||||
SortReGroups: flag.SortReGroups,
|
||||
Checksum: hashedFlag[:],
|
||||
ChoicesCost: flag.ChoicesCost,
|
||||
})
|
||||
|
|
|
|||
Reference in a new issue