Skip to content

Commit 53c0a5d

Browse files
committed
fix: correct flag alignment padding for flags without short names
1 parent bd8d98c commit 53c0a5d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

usage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ type flagInfo struct {
240240

241241
// displayName returns the flag name with optional short alias and type hint. When hasAnyShort is
242242
// true, flags without a short alias are padded to align with those that have one. Examples: "-v,
243-
// --verbose", "-o, --output string", " --config string", "--debug".
243+
// --verbose", "-o, --output string", " --config string", "--debug".
244244
func (f flagInfo) displayName(hasAnyShort bool) string {
245245
var name string
246246
if f.short != "" {
247247
name = "-" + f.short + ", " + f.name
248248
} else if hasAnyShort {
249-
name = " " + f.name
249+
name = " " + f.name
250250
} else {
251251
name = f.name
252252
}

usage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func TestWriteFlagSection(t *testing.T) {
448448
require.Contains(t, output, "-v, --verbose")
449449
require.Contains(t, output, "-o, --output string")
450450
// Flags without short aliases are padded to align with double-dash
451-
require.Contains(t, output, " --config string")
451+
require.Contains(t, output, " --config string")
452452
})
453453

454454
t.Run("no short flags means no padding", func(t *testing.T) {

0 commit comments

Comments
 (0)