Skip to content

Commit

Permalink
feat: students and groups on the command line are now regexps
Browse files Browse the repository at this point in the history
  • Loading branch information
obcode committed Nov 4, 2024
1 parent 2f39855 commit bf9fe36
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions config/students.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"regexp"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -58,8 +59,8 @@ func students(per Per, course, assignment string, onlyForStudentsOrGroups ...str
onlyForStudents := make([]string, 0, len(onlyForStudentsOrGroups))
for _, onlyStudent := range onlyForStudentsOrGroups {
for _, student := range studs {
if onlyStudent == student {
onlyForStudents = append(onlyForStudents, onlyStudent)
if ok, err := regexp.MatchString(onlyStudent, student); ok && err == nil {
onlyForStudents = append(onlyForStudents, student)
}
}
}
Expand Down Expand Up @@ -123,7 +124,7 @@ func groups(per Per, course, assignment string, onlyForStudentsOrGroups ...strin
onlyTheseGroups := make(map[string][]string)
for _, onlyGroup := range onlyForStudentsOrGroups {
for groupname, students := range groupsMap {
if onlyGroup == groupname {
if ok, err := regexp.MatchString(onlyGroup, groupname); ok && err == nil {
onlyTheseGroups[groupname] = students
}
}
Expand Down

0 comments on commit bf9fe36

Please sign in to comment.