Skip to content

Commit

Permalink
IniParser: write 'func' options with "ini-name"
Browse files Browse the repository at this point in the history
If a 'ini-name' tag is set on the option, write it to file even if the
option is a function.
  • Loading branch information
cdevienne committed Dec 12, 2019
1 parent c0795c8 commit e9ecd9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ini.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func writeGroupIni(cmd *Command, group *Group, namespace string, writer io.Write
comments := (options & IniIncludeComments) != IniNone

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

Expand Down
9 changes: 9 additions & 0 deletions ini_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ int-map = b:3
verbose = true
verbose = true
; Call phone number
call =
; A slice of pointers to string
; PtrSlice =
Expand Down Expand Up @@ -113,6 +116,9 @@ Opt =
; Show verbose debug information
; verbose =
; Call phone number
; call =
; A slice of pointers to string
; PtrSlice =
Expand Down Expand Up @@ -176,6 +182,9 @@ EnvDefault2 = env-def
; Show verbose debug information
; verbose =
; Call phone number
; call =
; A slice of pointers to string
; PtrSlice =
Expand Down

0 comments on commit e9ecd9d

Please sign in to comment.