1
0
mirror of https://github.com/ru-de/faq.git synced 2024-11-23 19:02:19 +00:00
faq-de/files/check_spell.go
2018-05-04 00:28:41 +02:00

54 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"fmt"
"os"
"github.com/ewgRa/ci-utils/diff_liner"
"github.com/ewgRa/ci-utils/hunspell_parser"
"github.com/google/go-github/github"
"flag"
"encoding/json"
)
func main() {
prLiner := flag.String("pr-liner", "", "Pull request liner")
hunspellParsedFile := flag.String("hunspell-parsed-file", "", "Hunspell parsed file name")
file := flag.String("file", "", "Hunspell parsed file name")
flag.Parse()
if *prLiner == "" || *hunspellParsedFile == "" || *file == "" {
flag.Usage()
os.Exit(1)
}
linerResp := diff_liner.ReadLinerResponse(*prLiner)
hunspellParsedResp := hunspell_parser.ReadHunspellParserResponse(*hunspellParsedFile)
for _, resp := range hunspellParsedResp {
prLine := linerResp.GetDiffLine(*file, resp.Line)
if prLine == 0 {
continue
}
body := fmt.Sprintf("Возможная ошибка в слове \"%s\", варианты правильного написания \"%s\". Если слово \"%s\" является правильным, добавьте его в files/dictionary.dic", resp.Word, resp.Alternative, resp.Word)
commitID := "FIXME XXX"
comment := &github.PullRequestComment{
Body: &body,
CommitID: &commitID,
Path: file,
Position: &prLine,
}
jsonData, err := json.Marshal(comment)
if err != nil {
panic(err)
}
fmt.Println(string(jsonData))
}
}