feat: show version
This commit is contained in:
parent
43a799e958
commit
198d329c8e
|
@ -38,6 +38,8 @@ jobs:
|
|||
run: make lint
|
||||
- name: Build
|
||||
run: make build
|
||||
- name: Version
|
||||
run: ./build/joj3 -v
|
||||
- name: Test
|
||||
run: |
|
||||
make prepare-test
|
||||
|
|
|
@ -35,9 +35,12 @@ func setupSlog() {
|
|||
slog.SetDefault(logger)
|
||||
}
|
||||
|
||||
var Version string
|
||||
|
||||
// Generally, err is used for runtime errors, and checkRes is used for the result of the checks.
|
||||
func main() {
|
||||
var gitWhitelist, metaFile, releaseTags []string
|
||||
showVersion := flag.Bool("v", false, "print current version")
|
||||
rootDir := flag.String("root", "", "")
|
||||
repo := flag.String("repo", "", "")
|
||||
localList := flag.String("localList", "", "")
|
||||
|
@ -50,6 +53,10 @@ func main() {
|
|||
parseMultiValueFlag(&metaFile, "meta", "")
|
||||
parseMultiValueFlag(&releaseTags, "releaseTags", "")
|
||||
flag.Parse()
|
||||
if *showVersion {
|
||||
fmt.Println(Version)
|
||||
return
|
||||
}
|
||||
setupSlog()
|
||||
var err error
|
||||
err = healthcheck.RepoSize()
|
||||
|
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
|
@ -92,16 +93,23 @@ func outputResult(outputPath string, results []stage.StageResult) error {
|
|||
var (
|
||||
metaConfPath string
|
||||
msg string
|
||||
showVersion *bool
|
||||
Version string
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&metaConfPath, "meta-conf", "meta-conf.toml", "meta config file path")
|
||||
flag.StringVar(&msg, "msg", "", "message to trigger the running, leave empty to use git commit message on HEAD")
|
||||
showVersion = flag.Bool("v", false, "print current version")
|
||||
}
|
||||
|
||||
func mainImpl() error {
|
||||
setupSlog(int(slog.LevelInfo)) // before conf is loaded
|
||||
flag.Parse()
|
||||
if *showVersion {
|
||||
fmt.Println(Version)
|
||||
return nil
|
||||
}
|
||||
if msg == "" {
|
||||
var err error
|
||||
msg, err = getCommitMsg()
|
||||
|
|
|
@ -9,9 +9,16 @@ import (
|
|||
"github.com/joint-online-judge/JOJ3/pkg/sample"
|
||||
)
|
||||
|
||||
var Version string
|
||||
|
||||
func main() {
|
||||
showVersion := flag.Bool("v", false, "print current version")
|
||||
score := flag.Int("score", 0, "score")
|
||||
flag.Parse()
|
||||
if *showVersion {
|
||||
fmt.Println(Version)
|
||||
return
|
||||
}
|
||||
res, err := sample.Run(sample.Conf{Score: *score})
|
||||
if err != nil {
|
||||
fmt.Fprint(os.Stderr, err)
|
||||
|
|
Loading…
Reference in New Issue
Block a user