diff --git a/plab/check.go b/plab/check.go new file mode 100644 index 0000000000000000000000000000000000000000..f4f14783c73a17b052726083d092a58ff78f0304 --- /dev/null +++ b/plab/check.go @@ -0,0 +1,58 @@ +package main + +import ( + "fmt" + "git.sch.bme.hu/insert-epic-projlab-team-name-here/tooling/plab/helpers" + "io/ioutil" + "os/exec" + "strings" +) + +var Check = helpers.Subcommand{ + Name: "check", + Command: func(args []string) { + if len(args) != 1 { + fmt.Println("usage: check <approved words list in a file>") + return + } + + huns := hunspell() + approved := approveds(args[0]) + + check(huns, approved) + }, + Help: "check the spell", +} + +func hunspell() []string { + b, e := exec.Command("bash", "-c", "hunspell -L -d hu_HU,en_GB,en_US -l -t $(find . -type f -name \"*.tex\" | tr \"\\n\" \" \")").Output() + if e != nil { + panic(e) + } + str := string(b) + return strings.Split(str, "\n") +} + +func approveds(filename string) []string { + b, e := ioutil.ReadFile(filename) + if e != nil { + panic(e) + } + str := string(b) + return strings.Split(str, "\n") +} + +func check(huns, approved []string) { + for _, h := range huns { + ignored := false + for _, a := range approved { + if strings.Contains(h, a) { + ignored = true + break + } + } + if !ignored { + fmt.Println(h) + } + } +} diff --git a/plab/main.go b/plab/main.go index 64c583e9cf24c5a6a72b3db3c905a7f47cefeb1c..db1be0c13173992602975280f3b498cf542a600c 100644 --- a/plab/main.go +++ b/plab/main.go @@ -6,7 +6,7 @@ import ( ) func main() { - mainCmds := helpers.CmdFrom(os.Args[0], "go projlab tool", Timetable, Javadoc, Classdiag) + mainCmds := helpers.CmdFrom(os.Args[0], "go projlab tool", Timetable, Javadoc, Classdiag, Check) if len(os.Args) < 2 { os.Args = append(os.Args, "help") }