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