feat: show banner when workspace is outdated (#4926)

* feat: show banner when workspace is outdated

* Address PR comments

* Fix: writer
This commit is contained in:
Marcin Tojek
2022-11-07 19:12:39 +01:00
committed by GitHub
parent f15854c179
commit 641aacf793
3 changed files with 91 additions and 1 deletions
+12 -1
View File
@@ -417,6 +417,17 @@ func isTTY(cmd *cobra.Command) bool {
// This accepts a reader to work with Cobra's "OutOrStdout"
// function for simple testing.
func isTTYOut(cmd *cobra.Command) bool {
return isTTYWriter(cmd, cmd.OutOrStdout)
}
// isTTYErr returns whether the passed reader is a TTY or not.
// This accepts a reader to work with Cobra's "ErrOrStderr"
// function for simple testing.
func isTTYErr(cmd *cobra.Command) bool {
return isTTYWriter(cmd, cmd.ErrOrStderr)
}
func isTTYWriter(cmd *cobra.Command, writer func() io.Writer) bool {
// If the `--force-tty` command is available, and set,
// assume we're in a tty. This is primarily for cases on Windows
// where we may not be able to reliably detect this automatically (ie, tests)
@@ -424,7 +435,7 @@ func isTTYOut(cmd *cobra.Command) bool {
if forceTty && err == nil {
return true
}
file, ok := cmd.OutOrStdout().(*os.File)
file, ok := writer().(*os.File)
if !ok {
return false
}