Skip to content

fix: Wrap help flags at 100 chars #2893

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

Merged
merged 1 commit into from
Jul 11, 2022
Merged

fix: Wrap help flags at 100 chars #2893

merged 1 commit into from
Jul 11, 2022

Conversation

mafredri
Copy link
Member

Because the actual flags take quite a bit of space, wrapping at 80
characters creates a very cramped output for e.g. coder server, for
this reasons, flags are wrapped at 100 chars (vs. standard 80).

The Consumes $ENV_FLAG message was put on a newline for consistency,
this should allow users to learn where to look for the informations.

Side note: we should perhaps stop adding period (.) at the end of flag
descriptions to be consistent, for instance, command helps usually don't
have one.

This change fixes the biggest issue in #2363, but not all --help
output is guaranteed (yet) to wrap at 80-100 chars.

Fixes #2363

Because the actual flags take quite a bit of space, wrapping at 80
characters creates a very cramped output for e.g. `coder server`, for
this reasons, flags are wrapped at 100 chars (vs. standard 80).

The `Consumes $ENV_FLAG` message was put on a newline for consistency,
this should allow users to learn where to look for the informations.

Side note: we should perhaps stop adding period (`.`) at the end of flag
descriptions to be consistent, for instance, command helps usually don't
have one.

This change fixes the biggest issue in #2363, but not all `--help`
output is guaranteed (yet) to wrap at 80-100 chars.

Fixes #2363
@mafredri mafredri self-assigned this Jul 11, 2022
@mafredri mafredri requested a review from a team July 11, 2022 13:46
@kylecarbs
Copy link
Member

Great change. The non-wrapped text was difficult to read!

@@ -348,12 +348,12 @@ func usageTemplate() string {

{{- if .HasAvailableLocalFlags}}
{{usageHeader "Flags:"}}
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}
{{.LocalFlags.FlagUsagesWrapped 100}}
Copy link
Member

Choose a reason for hiding this comment

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

TIL 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Same here, we have pflag to thank ❤️! 😄

@mafredri mafredri merged commit c768137 into main Jul 11, 2022
@mafredri mafredri deleted the mafredri/wrap-help-flags branch July 11, 2022 14:07
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.

Wrap --help command descriptions at 80 characters
3 participants