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

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

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