Skip to content

Commit cacaace

Browse files
committed
fix: don't append ... for fields with an explicit type
Fixes #346
1 parent a32b94b commit cacaace

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

kong_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -2460,3 +2460,18 @@ func TestApplyCalledOnce(t *testing.T) {
24602460
err = kctx.Run()
24612461
assert.NoError(t, err)
24622462
}
2463+
2464+
func TestCustomTypeNoEllipsis(t *testing.T) {
2465+
type CLI struct {
2466+
Flag []byte `type:"existingfile"`
2467+
}
2468+
var cli CLI
2469+
p := mustNew(t, &cli, kong.Exit(func(int) {}))
2470+
w := &strings.Builder{}
2471+
p.Stderr = w
2472+
p.Stdout = w
2473+
_, err := p.Parse([]string{"--help"})
2474+
assert.NoError(t, err)
2475+
help := w.String()
2476+
assert.NotContains(t, help, "...")
2477+
}

model.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ func (f *Flag) FormatPlaceHolder() string {
433433
return placeholderHelper.PlaceHolder(f)
434434
}
435435
tail := ""
436-
if f.Value.IsSlice() && f.Value.Tag.Sep != -1 {
436+
if f.Value.IsSlice() && f.Value.Tag.Sep != -1 && f.Tag.Type == "" {
437437
tail += string(f.Value.Tag.Sep) + "..."
438438
}
439439
if f.PlaceHolder != "" {
@@ -446,7 +446,7 @@ func (f *Flag) FormatPlaceHolder() string {
446446
return f.Default + tail
447447
}
448448
if f.Value.IsMap() {
449-
if f.Value.Tag.MapSep != -1 {
449+
if f.Value.Tag.MapSep != -1 && f.Tag.Type == "" {
450450
tail = string(f.Value.Tag.MapSep) + "..."
451451
}
452452
return "KEY=VALUE" + tail

0 commit comments

Comments
 (0)