sync: alert about unknown keys in challenge.txt
This commit is contained in:
parent
936ef09e33
commit
c8ece39cb2
3 changed files with 19 additions and 6 deletions
|
@ -7,7 +7,9 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
|
@ -133,12 +135,20 @@ func BuildExercice(i Importer, theme fic.Theme, epath string, dmap *map[int64]fi
|
|||
}
|
||||
|
||||
// Parse challenge.txt
|
||||
p, err = parseExerciceParams(i, epath)
|
||||
var md toml.MetaData
|
||||
p, md, err = parseExerciceParams(i, epath)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: challenge.txt: %s", edir, err))
|
||||
errs = append(errs, fmt.Sprintf("%q: %s", edir, err))
|
||||
return
|
||||
}
|
||||
|
||||
// Alert about unknown keys in challenge.txt
|
||||
if len(md.Undecoded()) > 0 {
|
||||
for _, k := range md.Undecoded() {
|
||||
errs = append(errs, fmt.Sprintf("%q: challenge.txt: unknown key %q found, check https://srs.nemunai.re/fic/files/challenge.html", edir, k))
|
||||
}
|
||||
}
|
||||
|
||||
if p.Gain == 0 {
|
||||
errs = append(errs, fmt.Sprintf("%q: challenge.txt: Undefined gain for challenge", edir))
|
||||
} else {
|
||||
|
|
Reference in a new issue