Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find features des...' (#75) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
All checks were successful
Security Scan / security (push) Successful in 23s
All checks were successful
Security Scan / security (push) Successful in 23s
This commit is contained in:
commit
c6c07f0ee4
2 changed files with 30 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -272,3 +273,29 @@ func TestSetStdin_Good_ResetNil(t *testing.T) {
|
||||||
SetStdin(nil)
|
SetStdin(nil)
|
||||||
assert.Same(t, os.Stdin, stdin)
|
assert.Same(t, os.Stdin, stdin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPromptHints_Good_UseStderr(t *testing.T) {
|
||||||
|
oldOut := os.Stdout
|
||||||
|
oldErr := os.Stderr
|
||||||
|
rOut, wOut, _ := os.Pipe()
|
||||||
|
rErr, wErr, _ := os.Pipe()
|
||||||
|
os.Stdout = wOut
|
||||||
|
os.Stderr = wErr
|
||||||
|
|
||||||
|
promptHint("try again")
|
||||||
|
promptWarning("invalid")
|
||||||
|
|
||||||
|
_ = wOut.Close()
|
||||||
|
_ = wErr.Close()
|
||||||
|
os.Stdout = oldOut
|
||||||
|
os.Stderr = oldErr
|
||||||
|
|
||||||
|
var stdout bytes.Buffer
|
||||||
|
var stderr bytes.Buffer
|
||||||
|
_, _ = io.Copy(&stdout, rOut)
|
||||||
|
_, _ = io.Copy(&stderr, rErr)
|
||||||
|
|
||||||
|
assert.Empty(t, stdout.String())
|
||||||
|
assert.Contains(t, stderr.String(), "try again")
|
||||||
|
assert.Contains(t, stderr.String(), "invalid")
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -39,11 +40,11 @@ type confirmConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptHint(msg string) {
|
func promptHint(msg string) {
|
||||||
fmt.Println(DimStyle.Render(compileGlyphs(msg)))
|
fmt.Fprintln(os.Stderr, DimStyle.Render(compileGlyphs(msg)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptWarning(msg string) {
|
func promptWarning(msg string) {
|
||||||
fmt.Println(WarningStyle.Render(compileGlyphs(msg)))
|
fmt.Fprintln(os.Stderr, WarningStyle.Render(compileGlyphs(msg)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultYes sets the default response to "yes" (pressing Enter confirms).
|
// DefaultYes sets the default response to "yes" (pressing Enter confirms).
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue