Skip to content

Commit

Permalink
Create formitychecker.go
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong <[email protected]>
  • Loading branch information
cubxxw authored Mar 27, 2024
1 parent 9feb71d commit 513feb6
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions formitychecker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"os"

"github.com/openimsdk/open-im-server/tools/formitychecker/checker"
"github.com/openimsdk/open-im-server/tools/formitychecker/config"
)

func main() {
var configPath string
flag.StringVar(&configPath, "config", "", "Path to the configuration file")
flag.Parse()

if configPath == "" {
configPath = os.Getenv("CONFIG_PATH")
}

if configPath == "" {
configPath = "config.yaml"
if _, err := os.Stat(".github/formitychecker.yaml"); err == nil {
configPath = ".github/formitychecker.yaml"
}
}

cfg, err := config.LoadConfig(configPath)
if err != nil {
fmt.Println("Error loading config:", err)
return
}

c := &checker.Checker{Config: cfg}
err = c.Check()
if err != nil {
fmt.Println("Error during check:", err)
os.Exit(1)
}

// if len(c.Errors) > 0 {
// fmt.Println("Found errors:")
// for _, errMsg := range c.Errors {
// fmt.Println("-", errMsg)
// }
// os.Exit(1)
// }

summaryJSON, err := json.MarshalIndent(c.Summary, "", " ")
if err != nil {
fmt.Println("Error marshalling summary:", err)
return
}

fmt.Println(string(summaryJSON))
}

0 comments on commit 513feb6

Please sign in to comment.