Skip to content
Myr

feat(style): trim line spaces (#767)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Lipgloss applies aligning on the string as given to it, and ascii art usually contain left whitespaces to align things. This adds an option to trim space on all lines of the input, before giving it to lipgloss, so aligning use only non-whitespace content.

authored by Carlos Alexandro Becker · committed by GitHub · parent 6a37a14 · Browse files · 3 files+15 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−0 removed

  • other:+15 added−0 removed

3 files+15 added−0 removed

added:style/ascii_a.txt+7 added
1 #2 # #3 # #4# #5#######6# #7# #
modified:style/command.go+7 added
23 unmodified lines
24 if text == "" {25 return errors.New("no input provided, see `gum style --help`")26 }27 }28 if o.Trim {29 var lines []string30 for _, line := range strings.Split(text, "\n") {31 lines = append(lines, strings.TrimSpace(line))32 }33 text = strings.Join(lines, "\n")34 }35 fmt.Println(o.Style.ToLipgloss().Render(text))36 return nil37}
modified:style/options.go+1 added
1 unmodified line
23// Options is the customization options for the style command.4type Options struct {5 Text []string `arg:"" optional:"" help:"Text to which to apply the style"`6 Trim bool `help:"Trim whitespaces on every input line" default:"false"`7 Style StylesNotHidden `embed:""`8}910// Styles is a flag set of possible styles.
59 unmodified lines