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

List of available commands is incorrectly aligned #4

Open
psrpinto opened this issue Jan 20, 2024 · 4 comments · May be fixed by #5
Open

List of available commands is incorrectly aligned #4

psrpinto opened this issue Jan 20, 2024 · 4 comments · May be fixed by #5

Comments

@psrpinto
Copy link

As visible in the screenshot below, the description of the the help and image commands is not aligned with the description of the completion command.

Screenshot 2024-01-20 at 12 23 52
@mikelorant
Copy link

Issue was caused by the upgrade of fatih/color from v1.15.0 to v1.16.0. Specifically the following commit: fatih/color@c33f29c

@mikelorant
Copy link

@ivanpirog Any chance you could take a look into this regression? The upstream change looks reasonable, so may require Colored Cobra to update how it applies the template.

@mikelorant
Copy link

Have a fairly simple fix to this issue:

tpl = re.ReplaceAllLiteralString(tpl, "{{rpad (CommandStyle .Name) (sum .NamePadding 12)}}")

Change this to:

tpl = re.ReplaceAllLiteralString(tpl, "{{rpad (CommandStyle .Name) (sum .NamePadding 15)}}")

Will also need the unit tests updated from 12 to 15` as well.

I will have a pull request up shortly.

mikelorant added a commit to mikelorant/coloredcobra that referenced this issue Apr 13, 2024
When upgrading the Color package from `v1.15.0` to `v1.16.0`, the list
of available commands becomes incorrectly aligned:

```text
Available Commands:

  completion Generate the autocompletion script for the specified shell
  help      Help about any command
  test      Test command for clarity
```

This was related to an [issue][1] where reset codes were not correctly
set. The [fix][2], which added extra reset codes, increased the length
of the string (which includes the ANSI codes) causing the amount of
padding to be insufficient.

This change, which upgrades the Color package to `v1.16.0`, also
increass the padding to account for the additional ANSI reset codes
that are now part of the string. This restores the text alignment to
how it was previously displayed.

Unit tests also needed to be updated to account for this change and are
passing successfully.

The Color package had updated its dependencies which has caused the
changes in `go.mod` to impact more than itself.

Fixes: ivanpirog#4

[1]: fatih/color#206
[2]: fatih/color#210

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
@mikelorant mikelorant linked a pull request Apr 13, 2024 that will close this issue
@mikelorant
Copy link

I have created pull request #5 to fix this issue. Would appreciate your confirmation @psrpinto if this fixes your issue.

daylinmorgan pushed a commit to daylinmorgan/coloredcobra that referenced this issue May 27, 2024
When upgrading the Color package from `v1.15.0` to `v1.16.0`, the list
of available commands becomes incorrectly aligned:

```text
Available Commands:

  completion Generate the autocompletion script for the specified shell
  help      Help about any command
  test      Test command for clarity
```

This was related to an [issue][1] where reset codes were not correctly
set. The [fix][2], which added extra reset codes, increased the length
of the string (which includes the ANSI codes) causing the amount of
padding to be insufficient.

This change, which upgrades the Color package to `v1.16.0`, also
increass the padding to account for the additional ANSI reset codes
that are now part of the string. This restores the text alignment to
how it was previously displayed.

Unit tests also needed to be updated to account for this change and are
passing successfully.

The Color package had updated its dependencies which has caused the
changes in `go.mod` to impact more than itself.

Fixes: ivanpirog#4

[1]: fatih/color#206
[2]: fatih/color#210

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
Signed-off-by: Daylin Morgan <me@dayl.in>
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 a pull request may close this issue.

2 participants