mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-09-10 12:58:57 +00:00
kubens: Start implementing stubs
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
30
internal/cmdutil/interactive.go
Normal file
30
internal/cmdutil/interactive.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package env
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
|
||||
"github.com/ahmetb/kubectx/internal/env"
|
||||
)
|
||||
|
||||
// isTerminal determines if given fd is a TTY.
|
||||
func isTerminal(fd *os.File) bool {
|
||||
return isatty.IsTerminal(fd.Fd())
|
||||
}
|
||||
|
||||
// fzfInstalled determines if fzf(1) is in PATH.
|
||||
func fzfInstalled() bool {
|
||||
v, _ := exec.LookPath("fzf")
|
||||
if v != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsInteractiveMode determines if we can do choosing with fzf.
|
||||
func IsInteractiveMode(stdout *os.File) bool {
|
||||
v := os.Getenv(env.EnvFZFIgnore)
|
||||
return v == "" && isTerminal(stdout) && fzfInstalled()
|
||||
}
|
Reference in New Issue
Block a user