mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 12:54:18 +02:00
fix too wide tables when in !tty mode
This commit is contained in:
@@ -18,8 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package printer
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"codeberg.org/scip/esctl/pkg/cfg"
|
||||
"github.com/fatih/color"
|
||||
"github.com/mattn/go-isatty"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -31,6 +34,10 @@ var (
|
||||
)
|
||||
|
||||
func Colorize(conf *cfg.Config, col, what string) string {
|
||||
if !isatty.IsTerminal(os.Stdout.Fd()) {
|
||||
return what
|
||||
}
|
||||
|
||||
switch conf.Output {
|
||||
case "json", "yaml":
|
||||
return what
|
||||
@@ -49,3 +56,11 @@ func Colorize(conf *cfg.Config, col, what string) string {
|
||||
|
||||
return what
|
||||
}
|
||||
|
||||
func Bold(what string) string {
|
||||
if !isatty.IsTerminal(os.Stdout.Fd()) {
|
||||
return what
|
||||
}
|
||||
|
||||
return bold(what)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user