Skip to content

Commit

Permalink
chore(cli): notify user when reading from stdin
Browse files Browse the repository at this point in the history
Only if stdin and stderr are both TTY. To inform users input
is expected, instead of appearing to "hang".
  • Loading branch information
Tieske committed Nov 27, 2023
1 parent fcd66c5 commit a1ec512
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/file/readfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"dario.cat/mergo"
"github.com/kong/go-database-reconciler/pkg/utils"
"golang.org/x/term"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -67,6 +68,9 @@ func getContent(filenames []string, mockEnvVars bool) (*Content, error) {
func getReaders(fileOrDir string) (map[string]io.Reader, error) {
// special case where `-` means stdin
if fileOrDir == "-" {
if term.IsTerminal(int(os.Stdin.Fd())) && term.IsTerminal(int(os.Stderr.Fd())) {
fmt.Fprintf(os.Stderr, "reading input from stdin...\n")
}
return map[string]io.Reader{"STDIN": os.Stdin}, nil
}

Expand Down

0 comments on commit a1ec512

Please sign in to comment.