mirror of
https://github.com/charmbracelet/glow
synced 2024-09-30 05:05:24 +00:00
Word-wrap text at 100 chars per default
The default can be overwritten by the user: ./gold -w 80
This commit is contained in:
parent
a6d648d863
commit
240eb4f2f8
6
main.go
6
main.go
|
@ -10,6 +10,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/mitchellh/go-wordwrap"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/charmbracelet/gold"
|
||||
|
@ -25,7 +26,9 @@ var (
|
|||
SilenceUsage: false,
|
||||
RunE: execute,
|
||||
}
|
||||
|
||||
style string
|
||||
width uint
|
||||
)
|
||||
|
||||
func readerFromArg(s string) (io.ReadCloser, error) {
|
||||
|
@ -91,7 +94,7 @@ func execute(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
out := r.RenderBytes(b)
|
||||
fmt.Printf("%s", string(out))
|
||||
fmt.Printf("%s", wordwrap.WrapString(string(out), width))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -103,4 +106,5 @@ func main() {
|
|||
|
||||
func init() {
|
||||
rootCmd.Flags().StringVarP(&style, "style", "s", "dark.json", "style JSON path")
|
||||
rootCmd.Flags().UintVarP(&width, "width", "w", 100, "word-wrap at width")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue