[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find features des... #94
4 changed files with 40 additions and 2 deletions
|
|
@ -70,6 +70,15 @@ func NewFrame(variant string) *Frame {
|
|||
}
|
||||
}
|
||||
|
||||
// WithOutput sets the destination writer for rendered output.
|
||||
// Pass nil to keep the current writer unchanged.
|
||||
func (f *Frame) WithOutput(out io.Writer) *Frame {
|
||||
if out != nil {
|
||||
f.out = out
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// Header sets the Header region model.
|
||||
func (f *Frame) Header(m Model) *Frame { f.setModel(RegionHeader, m); return f }
|
||||
|
||||
|
|
|
|||
|
|
@ -142,6 +142,16 @@ func TestFrame_Good(t *testing.T) {
|
|||
f := NewFrame("C")
|
||||
assert.Same(t, os.Stderr, f.out)
|
||||
})
|
||||
|
||||
t.Run("WithOutput sets output writer", func(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
f := NewFrame("C").WithOutput(&buf)
|
||||
f.Content(StaticModel("timed"))
|
||||
|
||||
f.Run()
|
||||
|
||||
assert.Contains(t, buf.String(), "timed")
|
||||
})
|
||||
}
|
||||
|
||||
func TestFrame_Bad(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -123,6 +123,15 @@ func NewTaskTracker() *TaskTracker {
|
|||
return &TaskTracker{out: os.Stderr}
|
||||
}
|
||||
|
||||
// WithOutput sets the destination writer for tracker output.
|
||||
// Pass nil to keep the current writer unchanged.
|
||||
func (tr *TaskTracker) WithOutput(out io.Writer) *TaskTracker {
|
||||
if out != nil {
|
||||
tr.out = out
|
||||
}
|
||||
return tr
|
||||
}
|
||||
|
||||
// Add registers a task and returns it for goroutine use.
|
||||
func (tr *TaskTracker) Add(name string) *TrackedTask {
|
||||
t := &TrackedTask{
|
||||
|
|
|
|||
|
|
@ -121,8 +121,7 @@ func TestTaskTracker_Good(t *testing.T) {
|
|||
|
||||
t.Run("wait completes for non-TTY", func(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
tr := NewTaskTracker()
|
||||
tr.out = &buf
|
||||
tr := NewTaskTracker().WithOutput(&buf)
|
||||
|
||||
task := tr.Add("quick")
|
||||
go func() {
|
||||
|
|
@ -135,6 +134,17 @@ func TestTaskTracker_Good(t *testing.T) {
|
|||
assert.Contains(t, buf.String(), "done")
|
||||
})
|
||||
|
||||
t.Run("WithOutput sets output writer", func(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
tr := NewTaskTracker().WithOutput(&buf)
|
||||
|
||||
tr.Add("quick").Done("done")
|
||||
tr.Wait()
|
||||
|
||||
assert.Contains(t, buf.String(), "quick")
|
||||
assert.Contains(t, buf.String(), "done")
|
||||
})
|
||||
|
||||
t.Run("name width alignment", func(t *testing.T) {
|
||||
tr := NewTaskTracker()
|
||||
tr.out = &bytes.Buffer{}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue