Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc191692

Browse files
authored
chore(cli): send help to stdout (#6865)
Minimizes pesky `2>&1` when working with help.
1 parentc2a96bd commitc191692

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

‎cli/help.go‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,13 @@ var usageWantsArgRe = regexp.MustCompile(`<.*>`)
267267
// output for a given command.
268268
funchelpFn() clibase.HandlerFunc {
269269
returnfunc(inv*clibase.Invocation)error {
270-
// We buffer writes to stderr because the newlineLimiter writes one
270+
// We use stdout for help and not stderr since there's no straightforward
271+
// way to distinguish between a user error and a help request.
272+
//
273+
// We buffer writes to stdout because the newlineLimiter writes one
271274
// rune at a time.
272-
stderrBuf:=bufio.NewWriter(inv.Stderr)
273-
out:=newlineLimiter{w:stderrBuf,limit:2}
275+
outBuf:=bufio.NewWriter(inv.Stdout)
276+
out:=newlineLimiter{w:outBuf,limit:2}
274277
tabwriter:=tabwriter.NewWriter(&out,0,0,2,' ',0)
275278
err:=usageTemplate.Execute(tabwriter,inv.Command)
276279
iferr!=nil {
@@ -280,7 +283,7 @@ func helpFn() clibase.HandlerFunc {
280283
iferr!=nil {
281284
returnerr
282285
}
283-
err=stderrBuf.Flush()
286+
err=outBuf.Flush()
284287
iferr!=nil {
285288
returnerr
286289
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp