mirror of
https://github.com/ovh/ovhcloud-cli.git
synced 2026-01-11 19:46:33 +00:00
Increase word wrap with auto-detect terminal width
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
This commit is contained in:
parent
75454fc612
commit
e20a532d65
2 changed files with 14 additions and 1 deletions
2
go.mod
2
go.mod
|
|
@ -11,6 +11,7 @@ require (
|
|||
github.com/charmbracelet/bubbletea v1.3.4
|
||||
github.com/charmbracelet/glamour v0.9.1
|
||||
github.com/charmbracelet/lipgloss v1.1.0
|
||||
github.com/charmbracelet/x/term v0.2.1
|
||||
github.com/getkin/kin-openapi v0.132.0
|
||||
github.com/ghodss/yaml v1.0.0
|
||||
github.com/jarcoal/httpmock v1.4.1
|
||||
|
|
@ -34,7 +35,6 @@ require (
|
|||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
|
||||
github.com/charmbracelet/x/ansi v0.8.0 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.0 // indirect
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/charmbracelet/glamour"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/charmbracelet/lipgloss/table"
|
||||
"github.com/charmbracelet/x/term"
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/ovh/ovhcloud-cli/internal/filters"
|
||||
"gopkg.in/ini.v1"
|
||||
|
|
@ -272,9 +273,21 @@ func OutputObject(value map[string]any, serviceName, templateContent string, out
|
|||
exitError("failed to execute template: %s", err)
|
||||
}
|
||||
|
||||
// Define word wrap for the renderer.
|
||||
// Use 80 characters by default, or the terminal width if available.
|
||||
wordWrap := 80
|
||||
termFd := os.Stdout.Fd()
|
||||
if term.IsTerminal(termFd) {
|
||||
termWidth, _, _ := term.GetSize(os.Stdout.Fd())
|
||||
if termWidth > 0 {
|
||||
wordWrap = termWidth
|
||||
}
|
||||
}
|
||||
|
||||
r, err := glamour.NewTermRenderer(
|
||||
glamour.WithAutoStyle(),
|
||||
glamour.WithPreservedNewLines(),
|
||||
glamour.WithWordWrap(wordWrap),
|
||||
)
|
||||
if err != nil {
|
||||
exitError("failed to init rendered: %s", err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue