Skip to content

Commit e9ecd9d

Browse files
committed
IniParser: write 'func' options with "ini-name"
If a 'ini-name' tag is set on the option, write it to file even if the option is a function.
1 parent c0795c8 commit e9ecd9d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ini.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func writeGroupIni(cmd *Command, group *Group, namespace string, writer io.Write
216216
comments := (options & IniIncludeComments) != IniNone
217217

218218
for _, option := range group.options {
219-
if option.isFunc() || option.Hidden {
219+
if option.Hidden || option.isFunc() && len(option.tag.Get("ini-name")) == 0 {
220220
continue
221221
}
222222

ini_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ int-map = b:3
4949
verbose = true
5050
verbose = true
5151
52+
; Call phone number
53+
call =
54+
5255
; A slice of pointers to string
5356
; PtrSlice =
5457
@@ -113,6 +116,9 @@ Opt =
113116
; Show verbose debug information
114117
; verbose =
115118
119+
; Call phone number
120+
; call =
121+
116122
; A slice of pointers to string
117123
; PtrSlice =
118124
@@ -176,6 +182,9 @@ EnvDefault2 = env-def
176182
; Show verbose debug information
177183
; verbose =
178184
185+
; Call phone number
186+
; call =
187+
179188
; A slice of pointers to string
180189
; PtrSlice =
181190

0 commit comments

Comments
 (0)