go(report,main): add flag -printreport
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-07-18 01:58:56 +02:00
parent 5eaeb9c692
commit 948a95fb7e
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 16 additions and 10 deletions

View File

@ -4,6 +4,7 @@
package main
import (
"flag"
"log"
"sync"
@ -16,6 +17,9 @@
func main() {
log.Println("starting math-optim version", "'"+version+"'")
doPrint := flag.Bool("printreport", true, "print report.tex to console")
flag.Parse()
// atm we're only doing Random search and SHC
algoCount := 2
@ -32,7 +36,7 @@ func main() {
report.SaveTexAllPics()
report.SaveTexAllTables()
report.SaveAndPrint()
report.SaveAndPrint(*doPrint)
log.Println("looks like we're done")
log.Println("run an equivalent of `pdflatex -clean -shell-escape -interaction=nonstopmode ./report.tex` to get a pdf")

View File

@ -80,7 +80,7 @@ func saveMetaSty() error {
// SaveAndPrint emits the tex files necessary to compile the report in full
// (report.tex, meta.sty) and prints the report.tex file to console.
func SaveAndPrint() {
func SaveAndPrint(doPrint bool) {
fname := "report.tex"
err := emitReportTex(fname)
@ -93,15 +93,17 @@ func SaveAndPrint() {
log.Fatal(err)
}
fmt.Fprint(os.Stderr, "\n* printing the report...\n\n")
if doPrint {
fmt.Fprint(os.Stderr, "\n* printing the report...\n\n")
fh, err := os.Open(fname)
if err != nil {
log.Fatal(err)
}
fh, err := os.Open(fname)
if err != nil {
log.Fatal(err)
}
_, err = io.Copy(os.Stdout, fh)
if err != nil {
log.Fatal(err)
_, err = io.Copy(os.Stdout, fh)
if err != nil {
log.Fatal(err)
}
}
}