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>
This commit is contained in:
Jim Wordelman 2026-07-06 22:35:42 -07:00 • committed by GitHub
commit bb821eed78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 124 additions and 16 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"
"github.com/steveyegge/beads/internal/audit"
"github.com/steveyegge/beads/internal/config"
"github.com/steveyegge/beads/internal/debug"
"github.com/steveyegge/beads/internal/metrics"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/types"
@ -182,7 +183,7 @@ the flags appear in the command line.`,
closedIssues = append(closedIssues, closedIssue)
}
} else {
fmt.Printf("%s Closed %s: %s\n", ui.RenderPass("✓"), formatFeedbackID(id, issueTitleOrEmpty(issue)), reason)
debug.PrintNormal("%s Closed %s: %s\n", ui.RenderPass("✓"), formatFeedbackID(id, issueTitleOrEmpty(issue)), reason)
}
}
@ -254,14 +255,14 @@ the flags appear in the command line.`,
if jsonOutput {
// JSON handled below
} else {
fmt.Printf("%s Auto-claimed next ready issue: %s (P%d)\n", ui.RenderPass("✓"), formatFeedbackID(nextIssue.ID, nextIssue.Title), nextIssue.Priority)
debug.PrintNormal("%s Auto-claimed next ready issue: %s (P%d)\n", ui.RenderPass("✓"), formatFeedbackID(nextIssue.ID, nextIssue.Title), nextIssue.Priority)
}
SetLastTouchedID(nextIssue.ID)
} else {
fmt.Fprintf(os.Stderr, "Warning: could not claim next issue %s: %v\n", nextIssue.ID, err)
}
} else if !jsonOutput {
fmt.Printf("\n%s No ready issues available to claim.\n", ui.RenderWarn("✨"))
debug.PrintNormal("\n%s No ready issues available to claim.\n", ui.RenderWarn("✨"))
}
}
@ -531,7 +532,7 @@ func autoCloseCompletedMolecule(ctx context.Context, s storage.DoltStorage, clos
}
if !jsonOutput {
fmt.Printf("%s Auto-closed completed molecule %s\n", ui.RenderPass("✓"), formatFeedbackID(moleculeID, root.Title))
debug.PrintNormal("%s Auto-closed completed molecule %s\n", ui.RenderPass("✓"), formatFeedbackID(moleculeID, root.Title))
}
}

View file

@ -703,9 +703,9 @@ var createCmd = &cobra.Command{
} else if silent {
fmt.Println(issue.ID)
} else {
fmt.Printf("%s Created issue: %s\n", ui.RenderPass("✓"), formatFeedbackID(issue.ID, issue.Title))
fmt.Printf(" Priority: P%d\n", issue.Priority)
fmt.Printf(" Status: %s\n", issue.Status)
debug.PrintNormal("%s Created issue: %s\n", ui.RenderPass("✓"), formatFeedbackID(issue.ID, issue.Title))
debug.PrintNormal(" Priority: P%d\n", issue.Priority)
debug.PrintNormal(" Status: %s\n", issue.Status)
maybeShowTip(store)
}

View file

@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
"github.com/steveyegge/beads/internal/audit"
"github.com/steveyegge/beads/internal/debug"
"github.com/steveyegge/beads/internal/metrics"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/timeparsing"
@ -521,7 +522,7 @@ create, update, show, or close operation).`,
updatedIssues = append(updatedIssues, updatedIssue)
}
} else {
fmt.Printf("%s Updated issue: %s\n", ui.RenderPass("✓"), formatFeedbackID(result.ResolvedID, updateTitle))
debug.PrintNormal("%s Updated issue: %s\n", ui.RenderPass("✓"), formatFeedbackID(result.ResolvedID, updateTitle))
}
// Track first successful update for last-touched

View file

@ -0,0 +1,106 @@
//go:build cgo
package main
import (
"os/exec"
"strings"
"testing"
)
// TestQuietFlagSuppressesSuccessOutput verifies that --quiet suppresses success
// output on create, close, and update while still exiting 0.
//
// Each sub-test: run the command with --quiet, capture stdout+stderr separately,
// assert stdout is empty and exit code is 0. Errors still flow to stderr (not
// tested here — the contract is "success output suppressed", not "all output").
func TestQuietFlagSuppressesSuccessOutput(t *testing.T) {
if testing.Short() {
t.Skip("skipping slow embedded-bd quiet-mode tests in short mode")
}
bd := buildEmbeddedBD(t)
dir := t.TempDir()
initGitRepoAt(t, dir)
env := bdEnv(dir)
// Initialize a beads store in the temp dir.
initCmd := exec.Command(bd, "init", "--prefix", "q", "--quiet")
initCmd.Dir = dir
initCmd.Env = env
if out, err := initCmd.CombinedOutput(); err != nil {
t.Fatalf("bd init failed: %v\n%s", err, out)
}
t.Run("create", func(t *testing.T) {
cmd := exec.Command(bd, "--quiet", "create", "quiet-create-test-title", "-p", "2")
cmd.Dir = dir
cmd.Env = env
stdout, stderr, err := runCommandBuffers(t, cmd)
if err != nil {
t.Fatalf("bd --quiet create failed: %v\nstdout:%s\nstderr:%s", err, stdout.String(), stderr.String())
}
if got := strings.TrimSpace(stdout.String()); got != "" {
t.Errorf("--quiet create: expected empty stdout, got:\n%s", got)
}
})
// Retrieve the issue ID created above for close/update tests.
listCmd := exec.Command(bd, "list", "--json", "--limit", "1")
listCmd.Dir = dir
listCmd.Env = env
listStdout, _, err := runCommandBuffers(t, listCmd)
if err != nil {
t.Fatalf("bd list --json failed: %v", err)
}
issueID := ""
for _, line := range strings.Split(listStdout.String(), "\n") {
line = strings.TrimSpace(line)
if strings.HasPrefix(line, `"id"`) {
parts := strings.SplitN(line, `"`, 4)
if len(parts) >= 4 {
issueID = parts[3]
}
break
}
}
if issueID == "" {
// Fallback: scan for first `"id": "..."` pattern
s := listStdout.String()
if idx := strings.Index(s, `"id": "`); idx >= 0 {
rest := s[idx+7:]
if end := strings.Index(rest, `"`); end >= 0 {
issueID = rest[:end]
}
}
}
if issueID == "" {
t.Skip("could not determine created issue ID; skipping close/update quiet tests")
}
t.Run("update", func(t *testing.T) {
cmd := exec.Command(bd, "--quiet", "update", issueID, "--priority", "1")
cmd.Dir = dir
cmd.Env = env
stdout, stderr, err := runCommandBuffers(t, cmd)
if err != nil {
t.Fatalf("bd --quiet update failed: %v\nstdout:%s\nstderr:%s", err, stdout.String(), stderr.String())
}
if got := strings.TrimSpace(stdout.String()); got != "" {
t.Errorf("--quiet update: expected empty stdout, got:\n%s", got)
}
})
t.Run("close", func(t *testing.T) {
cmd := exec.Command(bd, "--quiet", "close", issueID, "--reason", "quiet-test-done")
cmd.Dir = dir
cmd.Env = env
stdout, stderr, err := runCommandBuffers(t, cmd)
if err != nil {
t.Fatalf("bd --quiet close failed: %v\nstdout:%s\nstderr:%s", err, stdout.String(), stderr.String())
}
if got := strings.TrimSpace(stdout.String()); got != "" {
t.Errorf("--quiet close: expected empty stdout, got:\n%s", got)
}
})
}

View file

@ -42,16 +42,16 @@ func Printf(format string, args ...interface{}) {
}
}
// 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{}) {
// 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{}) {
// PrintlnNormal prints a line unless quiet mode is enabled.
func PrintlnNormal(args ...interface{}) {
if !quietMode {
fmt.Println(args...)
}

View file

@ -223,14 +223,14 @@ func TestPrintNormal(t *testing.T) {
r, w, _ := os.Pipe()
os.Stdout = w
printNormal(tt.format, tt.args...)
PrintNormal(tt.format, tt.args...)
w.Close()
var buf bytes.Buffer
io.Copy(&buf, r)
if got := buf.String(); got != tt.wantOutput {
t.Errorf("printNormal() output = %q, want %q", got, tt.wantOutput)
t.Errorf("PrintNormal() output = %q, want %q", got, tt.wantOutput)
}
})
}
@ -271,7 +271,7 @@ func TestPrintlnNormal(t *testing.T) {
r, w, _ := os.Pipe()
os.Stdout = w
printlnNormal(tt.args...)
PrintlnNormal(tt.args...)
w.Close()
var buf bytes.Buffer