From a3144fac455335d09ae90738c47e64714f323112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20BRAMI?= Date: Sun, 12 Jun 2022 22:58:26 +0200 Subject: [PATCH] feat: Avoid question in label. --- admin/sync/exercice_keys.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/admin/sync/exercice_keys.go b/admin/sync/exercice_keys.go index be6ff83e..ad460938 100644 --- a/admin/sync/exercice_keys.go +++ b/admin/sync/exercice_keys.go @@ -132,6 +132,12 @@ func buildKeyFlag(exercice *fic.Exercice, flag ExerciceFlag, flagline int, defau flag.Label = flag.Label[1:] } + if (flag.Label[0] == 'Q' || flag.Label[0] == 'q') && (flag.Label[1] == 'U' || flag.Label[1] == 'u') || + (flag.Label[0] == 'W' || flag.Label[0] == 'w') && (flag.Label[1] == 'H' || flag.Label[1] == 'h') { + errs = append(errs, fmt.Sprintf("%q: flag #%d: Label should not begin with %s. This seem to be a question. Reword your label as a description of the expected flag, `:` are automatically appended.", path.Base(exercice.Path), flagline, flag.Label[0:2])) + flag.Label = flag.Label[1:] + } + if flag.Label[len(flag.Label)-1] != ')' && flag.Label[len(flag.Label)-1] != '©' && !unicode.IsLetter(rune(flag.Label[len(flag.Label)-1])) && !unicode.IsDigit(rune(flag.Label[len(flag.Label)-1])) { errs = append(errs, fmt.Sprintf("%q: flag #%d: Label should not end with punct (%q). Reword your label as a description of the expected flag, `:` are automatically appended.", path.Base(exercice.Path), flagline, flag.Label[len(flag.Label)-1])) }