Skip to content

cobrautil/templates: support custom formats in usages #752

Merged
mmatczuk merged 8 commits intomainfrom
hg/print_endl_in_help_flag
Mar 25, 2024
Merged

cobrautil/templates: support custom formats in usages #752
mmatczuk merged 8 commits intomainfrom
hg/print_endl_in_help_flag

Conversation

@Choraden
Copy link
Contributor

This patch implements custom formatting of <br>,<ex>, and <link ...> for help and markdown printers.

…time

This simplifies the function logic as this condition was always true:
- getFlagFormat returns "(-)%s(,) --%s%s%s%s\n%s%s"
- this makes writeFlag always return string with at least one '\n'
- this makes the "len(flagAndUsage) > 1" condition true, regardless of the usage content

Moreover, it should wordwrap every usage line to keep it tidy.
@Choraden Choraden force-pushed the hg/print_endl_in_help_flag branch from 073af8c to 4b05de6 Compare March 21, 2024 12:36

usageWithBreakLines := strings.ReplaceAll(usageStr, "<br>", "\n\n")
wrappedUsages := wordwrap.WrapString(usageWithBreakLines, p.wrapLimit-offset)
usageWithExamples := strings.ReplaceAll(usageWithBreakLines, "<ex>", "\"")
Copy link
Contributor

@mmatczuk mmatczuk Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about <code> and </code>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@mmatczuk mmatczuk merged commit e738fe8 into main Mar 25, 2024
@mmatczuk mmatczuk deleted the hg/print_endl_in_help_flag branch March 25, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants