From 4181f77b35000f6e05b65529ff38f91f83447b44 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Wed, 29 Nov 2023 15:36:17 +0100 Subject: [PATCH] chore(cli): notify user when reading from stdin (#17) --- pkg/file/readfile.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/file/readfile.go b/pkg/file/readfile.go index f626732..de553d3 100644 --- a/pkg/file/readfile.go +++ b/pkg/file/readfile.go @@ -13,6 +13,7 @@ import ( "dario.cat/mergo" "github.com/kong/go-database-reconciler/pkg/utils" + "golang.org/x/term" "sigs.k8s.io/yaml" ) @@ -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 }