output to file by default

This commit is contained in:
2026-05-06 16:41:23 -04:00
parent e6fa98f707
commit 7b673ef443

View File

@@ -5,6 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt"
"io" "io"
"log/slog" "log/slog"
"net/http" "net/http"
@@ -88,12 +89,13 @@ func filejson[T any](path string) ([]T, error) {
} }
func main() { func main() {
ts := time.Now().UTC().Format(time.DateOnly) // can't use RFC3339 because :s in filename
var ( var (
dumpDir string dumpDir string
out string out string
) )
flag.StringVar(&dumpDir, "dump", ".", "`dir`ectory containing umadump output files") flag.StringVar(&dumpDir, "dump", ".", "`dir`ectory containing umadump output files")
flag.StringVar(&out, "o", "", "output `file` (default stdout)") flag.StringVar(&out, "o", fmt.Sprintf("uma-col-all-%s.json", ts), "output `file` (stdout if empty)")
flag.Parse() flag.Parse()
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
@@ -142,7 +144,7 @@ func main() {
Game: "umamusume", Game: "umamusume",
Type: "collection", Type: "collection",
Version: 4, Version: 4,
Timestamp: time.Now().String(), Timestamp: ts,
Servers: map[string]CollectionServer{ Servers: map[string]CollectionServer{
"en": { "en": {
CharCards: charaLevels, CharCards: charaLevels,