Skip to content

Commit f99ef67

Browse files
committed
fix a bug that caused shorthand name for slice doesn't get generated
1 parent 8628179 commit f99ef67

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

example/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
type ZipCLI struct {
1515
ConfigFile string `short:"c" usage:"working profile"`
1616
SvrAddr net.IP `usage:"server address to download the archive" complete:"SvrComplete"` //using completer method SvrComplete for shell completion
17-
BackupAddrList []netip.Addr `usage:"backup server address list"`
17+
BackupAddrList []netip.Addr `short:"b" usage:"backup server address list"`
1818
Compress struct {
1919
Loop uint `base:"16" short:"l" usage:"number of compress iterations"`
2020
Profile string `usage:"compress profile" choices:"p1,p2,p3"` //using choices for shell compeltion

list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ func getListType(ref reflect.Value, tag reflect.StructTag) (*listType, error) {
116116
return &newval, nil
117117
}
118118

119-
func processList(fs *flag.FlagSet, ref reflect.Value, tag reflect.StructTag, name, usage string) error {
119+
func processList(fs *flag.FlagSet, ref reflect.Value, tag reflect.StructTag, name, short, usage string) error {
120120
newlist, err := getListType(ref, tag)
121121
if err != nil {
122122
return err
123123
}
124-
fs.Var(newlist, name, usage)
124+
fs.VarP(newlist, name, short, usage)
125+
125126
return nil
126127
}

myflags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ func (filler *Filler) walk(root, inV reflect.Value, nameprefix string, isAct boo
734734
}
735735
}
736736
if process {
737-
err = processList(fs, field.Addr(), fieldT.Tag, fname, usage)
737+
err = processList(fs, field.Addr(), fieldT.Tag, fname, fshort, usage)
738738
if err != nil {
739739
return err
740740
}

0 commit comments

Comments
 (0)