mirror of
https://github.com/mudler/luet.git
synced 2025-09-09 02:59:30 +00:00
Massive UX rewrite
- Ditch multiple libraries for progressbar, spinner, colors and replace with pterm - Detect when running on terminal and disable automatically spinner - Add support for multiple progress bars - Huge rewrite of the configuration part. No more crazy stuff with viper CLI commands now correctly overrides default config file as expected - Limit banner to be displayed on relevant parts Fixes #211 Fixes #105 Fixes #247 Fixes #233
This commit is contained in:
12
pkg/helpers/terminal/terminal_check_bsd.go
Normal file
12
pkg/helpers/terminal/terminal_check_bsd.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
|
||||
package terminal
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const ioctlReadTermios = unix.TIOCGETA
|
||||
|
||||
func isTerminal(fd int) bool {
|
||||
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
|
||||
return err == nil
|
||||
}
|
17
pkg/helpers/terminal/terminal_check_general.go
Normal file
17
pkg/helpers/terminal/terminal_check_general.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// +build !windows,!nacl,!plan9
|
||||
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func IsTerminal(w io.Writer) bool {
|
||||
switch v := w.(type) {
|
||||
case *os.File:
|
||||
return isTerminal(int(v.Fd()))
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
11
pkg/helpers/terminal/terminal_check_no_terminal.go
Normal file
11
pkg/helpers/terminal/terminal_check_no_terminal.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// +build js nacl plan9
|
||||
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
func IsTerminal(w io.Writer) bool {
|
||||
return false
|
||||
}
|
11
pkg/helpers/terminal/terminal_check_solaris.go
Normal file
11
pkg/helpers/terminal/terminal_check_solaris.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||
func isTerminal(fd int) bool {
|
||||
_, err := unix.IoctlGetTermio(fd, unix.TCGETA)
|
||||
return err == nil
|
||||
}
|
12
pkg/helpers/terminal/terminal_check_unix.go
Normal file
12
pkg/helpers/terminal/terminal_check_unix.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// +build linux aix zos
|
||||
|
||||
package terminal
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const ioctlReadTermios = unix.TCGETS
|
||||
|
||||
func isTerminal(fd int) bool {
|
||||
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
|
||||
return err == nil
|
||||
}
|
27
pkg/helpers/terminal/terminal_check_windows.go
Normal file
27
pkg/helpers/terminal/terminal_check_windows.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// +build windows
|
||||
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func IsTerminal(w io.Writer) bool {
|
||||
switch v := w.(type) {
|
||||
case *os.File:
|
||||
handle := windows.Handle(v.Fd())
|
||||
var mode uint32
|
||||
if err := windows.GetConsoleMode(handle, &mode); err != nil {
|
||||
return false
|
||||
}
|
||||
mode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||
if err := windows.SetConsoleMode(handle, mode); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user