Skip to content

Commit

Permalink
refactor: add ParseMetaKeyFlagFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
hui.wang committed Jan 20, 2022
1 parent 6a1bab0 commit f653648
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions gen_options_optiongen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions option.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func OptionsOptionDeclareWithDefault() interface{} {
"TagNameForDefaultValue": string(DefaultValueTagName),
// annotation@ReplaceFlagSetUsage(comment="是否替换FlagSet的Usage,使用xconf内置版本")
"ReplaceFlagSetUsage": true,
// annotation@ParseMetaKeyFlagFiles(comment="是否解析flag中的MetaKeyFlagFiles指定的文件")
// 当一个app中有多个根配置,只能有一个根配置解析flag中的配置文件
"ParseMetaKeyFlagFiles": true,
// annotation@StringAlias(comment="值别名")
"StringAlias": (map[string]string)(map[string]string{
"math.MaxInt": strconv.Itoa(maxInt),
Expand Down
2 changes: 1 addition & 1 deletion xconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (x *XConf) parseFlagFilesForXConf(flagSet *flag.FlagSet, args ...string) (f
return
}

if v := flagData[MetaKeyFlagFiles]; v != nil {
if v := flagData[MetaKeyFlagFiles]; v != nil && x.cc.ParseMetaKeyFlagFiles {
filesToParse = strings.Split(strings.Trim(v.(string), " "), ",")
x.cc.LogDebug(fmt.Sprintf("config files changed from:%v to %v provided by FlagSet", x.cc.Files, filesToParse))
}
Expand Down

0 comments on commit f653648

Please sign in to comment.