Merge pull request #10216 from nobe4/improve-padded-display

fix: padded display
This commit is contained in:
Andy Feller 2025-01-10 13:45:51 -05:00 committed by GitHub
commit a6ea8fe4ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,6 +11,7 @@ import (
"path"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
@ -469,18 +470,14 @@ func (m *Manager) Upgrade(name string, force bool) error {
}
func (m *Manager) upgradeExtensions(exts []*Extension, force bool) error {
var longestExtName = 0
for _, ext := range exts {
l := len(ext.Name())
if len(ext.Name()) > longestExtName {
longestExtName = l
}
}
format := fmt.Sprintf("[%%%ds]: ", longestExtName)
var longestExt = slices.MaxFunc(exts, func(a, b *Extension) int {
return len(a.Name()) - len(b.Name())
})
var longestExtName = len(longestExt.Name())
var failed bool
for _, f := range exts {
fmt.Fprintf(m.io.Out, format, f.Name())
fmt.Fprintf(m.io.Out, "[%*s]: ", longestExtName, f.Name())
currentVersion := displayExtensionVersion(f, f.CurrentVersion())
err := m.upgradeExtension(f, force)
if err != nil {