Implement flag type 'text': this is like keys, but on multiple lines
This commit is contained in:
parent
8f998485bb
commit
47ba134b55
9 changed files with 30 additions and 14 deletions
|
@ -116,7 +116,7 @@ func buildKeyFlag(exercice fic.Exercice, flag ExerciceFlag, flagline int, defaul
|
|||
}
|
||||
flag.Label = prep + flag.Label
|
||||
|
||||
if !isFullGraphic(raw) {
|
||||
if (flag.Type == "text" && !isFullGraphic(strings.Replace(raw, "\n", "", -1))) || (flag.Type != "text" && !isFullGraphic(raw)) {
|
||||
errs = append(errs, fmt.Sprintf("%q: WARNING flag #%d: non-printable characters in flag, is this really expected?", path.Base(exercice.Path), flagline))
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,7 @@ func buildKeyFlag(exercice fic.Exercice, flag ExerciceFlag, flagline int, defaul
|
|||
Label: flag.Label,
|
||||
Help: flag.Help,
|
||||
IgnoreCase: !flag.CaseSensitive,
|
||||
Multiline: flag.Type == "text",
|
||||
ValidatorRegexp: validatorRegexp(flag.ValidatorRe),
|
||||
Checksum: hashedFlag[:],
|
||||
ChoicesCost: flag.ChoicesCost,
|
||||
|
@ -191,6 +192,8 @@ func buildExerciceFlag(i Importer, exercice fic.Exercice, flag ExerciceFlag, nli
|
|||
flag.Type = "key"
|
||||
case "key":
|
||||
flag.Type = "key"
|
||||
case "text":
|
||||
flag.Type = "text"
|
||||
case "vector":
|
||||
flag.Type = "vector"
|
||||
case "ucq":
|
||||
|
@ -198,11 +201,11 @@ func buildExerciceFlag(i Importer, exercice fic.Exercice, flag ExerciceFlag, nli
|
|||
case "mcq":
|
||||
flag.Type = "mcq"
|
||||
default:
|
||||
errs = append(errs, fmt.Sprintf("%q: flag #%d: invalid type of flag: should be 'key', 'mcq', 'ucq' or 'vector'.", path.Base(exercice.Path), nline+1))
|
||||
errs = append(errs, fmt.Sprintf("%q: flag #%d: invalid type of flag: should be 'key', 'text', 'mcq', 'ucq' or 'vector'.", path.Base(exercice.Path), nline+1))
|
||||
return
|
||||
}
|
||||
|
||||
if flag.Type == "key" || flag.Type == "ucq" || flag.Type == "vector" {
|
||||
if flag.Type == "key" || flag.Type == "text" || flag.Type == "ucq" || flag.Type == "vector" {
|
||||
addedFlag, choices, berrs := buildKeyFlag(exercice, flag, nline+1, "Flag")
|
||||
if len(berrs) > 0 {
|
||||
errs = append(errs, berrs...)
|
||||
|
|
Reference in a new issue