Initial commit:

Added framework to generate DOT and png files of character map chart
from data folder.
Added all figures in the 1-2 chapters.
Added font file SimSum for render chart
This commit is contained in:
2024-09-02 04:59:36 +00:00
commit 8caf0ac3aa
36 changed files with 1236 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
package main
import (
"os"
"xyj-figures/pkg/batch"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var (
rootCmd = &cobra.Command{
Use: "xyj-figures",
Short: "A binary to generate map chart for figures in 西游记",
Run: func(cmd *cobra.Command, args []string) {
es, rs, errs := batch.LoadFolder("data")
if errs != nil {
log.Errorf("unable to load data on folder %s: %v", "data", errs)
}
log.Infof("loaded %d entities and %d relationships", len(es), len(rs))
ns, rs, errs := batch.DistillData(es, rs)
if errs != nil {
log.Errorf("unable to distill data: %v", errs)
}
errs = batch.Save("output/output.dot", ns, rs)
if errs != nil {
log.Errorf("unable to save dot: %v", errs)
}
},
}
)
// Execute executes the root command.
func Execute() error {
return rootCmd.Execute()
}
func main() {
log.SetFormatter(&log.JSONFormatter{})
// Output to stdout instead of the default stderr
// Can be any io.Writer, see below for File example
log.SetOutput(os.Stdout)
// Only log the warning severity or above.
log.SetLevel(log.InfoLevel)
if err := rootCmd.Execute(); err != nil {
log.Fatalf("failed to exec cmd: %v", err)
os.Exit(1)
}
}