mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 14:14:17 +00:00
Automatically use the notty style when stdout is no terminal
If the user provided a style flag, this still takes precedence.
This commit is contained in:
parent
95670866e0
commit
de91f6ae53
1 changed files with 7 additions and 6 deletions
13
main.go
13
main.go
|
@ -106,12 +106,13 @@ func execute(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
r := gold.NewPlainTermRenderer()
|
||||
if isatty.IsTerminal(os.Stdout.Fd()) {
|
||||
r, err = gold.NewTermRenderer(style)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !isatty.IsTerminal(os.Stdout.Fd()) &&
|
||||
!cmd.Flags().Changed("style") {
|
||||
style = "notty"
|
||||
}
|
||||
r, err := gold.NewTermRenderer(style)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.WordWrap = int(width)
|
||||
|
||||
|
|
Loading…
Reference in a new issue