Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(style): trim line spaces #767

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions style/ascii_a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# #
# #
# #
#######
# #
# #
7 changes: 7 additions & 0 deletions style/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions style/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:""`
}

Expand Down
Loading