mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 18:08:30 +02:00
tea comment: handle piped stdin (#322)
fixes #321 Co-authored-by: Norwin Roosen <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/322 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Norwin <noerw@noreply.gitea.io> Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
@ -26,7 +26,7 @@ func ShowCommentsMaybeInteractive(ctx *context.TeaContext, idx int64, totalComme
|
||||
return err
|
||||
}
|
||||
print.Comments(comments)
|
||||
} else if isInteractive() && !ctx.IsSet("comments") {
|
||||
} else if IsInteractive() && !ctx.IsSet("comments") {
|
||||
// if we're interactive, but --comments hasn't been explicitly set to false
|
||||
if err := ShowCommentsPaginated(ctx, idx, totalComments); err != nil {
|
||||
fmt.Printf("error while loading comments: %v\n", err)
|
||||
@ -70,6 +70,11 @@ func ShowCommentsPaginated(ctx *context.TeaContext, idx int64, totalComments int
|
||||
}
|
||||
|
||||
// IsInteractive checks if the output is piped, but NOT if the session is run interactively..
|
||||
func isInteractive() bool {
|
||||
func IsInteractive() bool {
|
||||
return terminal.IsTerminal(int(os.Stdout.Fd()))
|
||||
}
|
||||
|
||||
// IsStdinPiped checks if stdin is piped
|
||||
func IsStdinPiped() bool {
|
||||
return !terminal.IsTerminal(int(os.Stdin.Fd()))
|
||||
}
|
||||
|
Reference in New Issue
Block a user