Skip to content
Snippets Groups Projects
Verified Commit 3ba52b0c authored by Réthelyi Bálint's avatar Réthelyi Bálint :no_mouth:
Browse files

check spell

parent 729e08d7
No related branches found
No related tags found
No related merge requests found
Pipeline #6479 passed
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)
}
}
}
......@@ -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")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment