JOJ3/cmd/sample/main.go
张泊明518370910136 c474a5d493
All checks were successful
submodules sync / sync (push) Successful in 47s
build / build (push) Successful in 1m48s
build / trigger-build-image (push) Successful in 9s
docs(cmd): move README content to package comments (#85)
2025-02-11 11:16:38 -05:00

36 lines
685 B
Go

// Package main provides a sample executable that demonstrates how JOJ3 works.
// Its output should be parsed by the sample parser.
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
"github.com/joint-online-judge/JOJ3/pkg/sample"
)
var Version string
func main() {
showVersion := flag.Bool("version", 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)
os.Exit(1)
}
b, err := json.Marshal(res)
if err != nil {
fmt.Fprint(os.Stderr, err)
os.Exit(1)
}
fmt.Printf("%s", b)
}