mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
+12
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user