libfic: New function to analyze number flag
This commit is contained in:
parent
6aead541d6
commit
64feef8b95
2 changed files with 42 additions and 29 deletions
|
|
@ -236,35 +236,10 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||
}
|
||||
|
||||
if strings.HasPrefix(flag.Type, "number") {
|
||||
fields := strings.Split(flag.Type, ",")
|
||||
if len(fields) == 4 {
|
||||
flag.Type = fields[0]
|
||||
|
||||
var tmp_min, tmp_max, tmp_step float64
|
||||
|
||||
if len(fields[1]) > 0 {
|
||||
tmp_min, err = strconv.ParseFloat(fields[1], 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
flag.Min = &tmp_min
|
||||
}
|
||||
|
||||
if len(fields[2]) > 0 {
|
||||
tmp_max, err = strconv.ParseFloat(fields[2], 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
flag.Max = &tmp_max
|
||||
}
|
||||
|
||||
if len(fields[3]) > 0 {
|
||||
tmp_step, err = strconv.ParseFloat(fields[3], 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
flag.Step = &tmp_step
|
||||
}
|
||||
flag.Type = "number"
|
||||
flag.Min, flag.Max, flag.Step, err = AnalyzeNumberFlag(flag.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue