diff --git a/style/ascii_a.txt b/style/ascii_a.txt new file mode 100644 index 000000000..ba425ecbe --- /dev/null +++ b/style/ascii_a.txt @@ -0,0 +1,7 @@ + # + # # + # # +# # +####### +# # +# # diff --git a/style/command.go b/style/command.go index 80390fa14..be04c8453 100644 --- a/style/command.go +++ b/style/command.go @@ -25,6 +25,13 @@ func (o Options) Run() error { return errors.New("no input provided, see `gum style --help`") } } + if o.Trim { + var lines []string + for _, line := range strings.Split(text, "\n") { + lines = append(lines, strings.TrimSpace(line)) + } + text = strings.Join(lines, "\n") + } fmt.Println(o.Style.ToLipgloss().Render(text)) return nil } diff --git a/style/options.go b/style/options.go index 906b551d5..cd2251d97 100644 --- a/style/options.go +++ b/style/options.go @@ -3,6 +3,7 @@ package style // Options is the customization options for the style command. type Options struct { Text []string `arg:"" optional:"" help:"Text to which to apply the style"` + Trim bool `help:"Trim whitespaces on every input line" default:"false"` Style StylesNotHidden `embed:""` }