From f22b663fb6244100a2502145899c40065d6bf5c9 Mon Sep 17 00:00:00 2001 From: Ben Garrett Date: Tue, 30 Mar 2021 10:44:50 +0800 Subject: [PATCH] Tweaked prints. --- lib/cmd/new.go | 17 ++++++----------- lib/demozoo/demozoo.go | 10 +++++++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/cmd/new.go b/lib/cmd/new.go index ab9c54fb..d70f11c7 100644 --- a/lib/cmd/new.go +++ b/lib/cmd/new.go @@ -30,43 +30,38 @@ var newCmd = &cobra.Command{ fix database`, Run: func(cmd *cobra.Command, args []string) { config.Check() - // demozoo handler + color.Info.Println("Scan for new demozoo submissions") dz := demozoo.Request{ All: false, Overwrite: false, Refresh: false, Simulate: false, } - color.Info.Println("scan for new demozoo submissions") if err := dz.Queries(); err != nil { logs.Fatal(err) } - // proofs handler + color.Info.Println("Scan for new proof submissions") p := proof.Request{ Overwrite: false, AllProofs: false, HideMissing: false, } - color.Info.Println("scan for new proof submissions") if err := p.Queries(); err != nil { logs.Fatal(err) } - // missing image previews - color.Info.Println("generate missing images") + color.Info.Println("Generate missing images") if err := images.Fix(false); err != nil { logs.Fatal(err) } - // missing text file previews - color.Info.Println("generate missing text previews") + color.Info.Println("Generate missing text previews") if err := text.Fix(false); err != nil { logs.Fatal(err) } - // fix database entries - color.Info.Println("fix demozoo data conflicts") + color.Info.Println("Fix demozoo data conflicts") if err := demozoo.Fix(); err != nil { log.Fatal(err) } - color.Info.Println("fix malformed database entries") + color.Info.Println("Fix malformed database entries") if err := database.Fix(); err != nil { log.Fatal(err) } diff --git a/lib/demozoo/demozoo.go b/lib/demozoo/demozoo.go index d23c3210..3047e8d2 100644 --- a/lib/demozoo/demozoo.go +++ b/lib/demozoo/demozoo.go @@ -159,7 +159,9 @@ func (req Request) Queries() error { if err = st.sumTotal(records{rows, scanArgs, values}, req); err != nil { return fmt.Errorf("req queries sum total: %w", err) } - if st.total > 1 { + if st.total == 0 { + logs.Println("nothing to do") + } else { logs.Println("Total records", st.total) } rows, err = db.Query(stmt) @@ -182,7 +184,6 @@ func (req Request) Queries() error { logs.Danger(fmt.Errorf("request queries new record: %w", err)) continue } - fmt.Println() logs.Printcrf(r.String(st.total)) if update := r.check(); !update { continue @@ -208,6 +209,9 @@ func (req Request) Queries() error { st.print() return nil } + if st.total > 0 { + fmt.Println() + } st.summary(time.Since(start)) return nil } @@ -256,7 +260,7 @@ func (st stat) print() { func (st stat) summary(elapsed time.Duration) { t := fmt.Sprintf("Total Demozoo items handled: %v, time elapsed %.1f seconds", st.count, elapsed.Seconds()) - logs.Println("\n" + strings.Repeat("─", len(t))) + logs.Println(strings.Repeat("─", len(t))) logs.Println(t) if st.missing > 0 { logs.Println("UUID files not found:", st.missing)