beads/internal/debug/debug.go
Jim Wordelman bb821eed78
feat(verbosity): wire --quiet into create/close/update (bd-au0.10) (#4058)
* feat(verbosity): export debug.PrintNormal; wire --quiet into create/close/update (bd-au0.10)

Exports the previously-private printNormal/printlnNormal helpers as
debug.PrintNormal/PrintlnNormal and applies them to the three most
user-visible write commands so --quiet suppresses success output.
--verbose and error output are unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(verbosity): add TestQuietFlagSuppressesSuccessOutput embedded tests

Adds TestQuietFlagSuppressesSuccessOutput with create, update, and close
subtests that assert --quiet produces empty stdout on success. Each test
initializes a fresh embedded-Dolt beads dir, runs the command with --quiet,
and asserts stdout is empty.

Absorbed maintainer-side per synthesis fix plan — contributor's
production wiring is untouched.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-06 22:35:42 -07:00

58 lines
1.1 KiB
Go

package debug
import (
"fmt"
"os"
)
var (
enabled = os.Getenv("BD_DEBUG") != ""
verboseMode = false
quietMode = false
)
func Enabled() bool {
return enabled || verboseMode
}
// SetVerbose enables verbose/debug output
func SetVerbose(verbose bool) {
verboseMode = verbose
}
// SetQuiet enables quiet mode (suppress non-essential output)
func SetQuiet(quiet bool) {
quietMode = quiet
}
// IsQuiet returns true if quiet mode is enabled
func IsQuiet() bool {
return quietMode
}
func Logf(format string, args ...interface{}) {
if enabled || verboseMode {
fmt.Fprintf(os.Stderr, format, args...)
}
}
func Printf(format string, args ...interface{}) {
if enabled || verboseMode {
fmt.Printf(format, args...)
}
}
// PrintNormal prints output unless quiet mode is enabled.
// Use this for normal informational output that should be suppressed in quiet mode.
func PrintNormal(format string, args ...interface{}) {
if !quietMode {
fmt.Printf(format, args...)
}
}
// PrintlnNormal prints a line unless quiet mode is enabled.
func PrintlnNormal(args ...interface{}) {
if !quietMode {
fmt.Println(args...)
}
}