Skip to content

Conversation

@jl2005
Copy link

@jl2005 jl2005 commented Jul 6, 2019

通过在flag.Parse() 之前调用 configo.AddFlags() 方法,即可实现将配置文件中的参数添加到flag中,从而可以通过命令行设置配置文件参数。

@jl2005
Copy link
Author

jl2005 commented Jul 6, 2019

@shafreeck 看一下这种实现方式是否可行。

@shafreeck shafreeck self-requested a review July 8, 2019 10:48
configo.go Outdated
}

// apply flag param
ApplyFlags(v)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉放到这里,或默认启用flag不太合适,比如我只想解析toml,不想使用flag呢?

是不是考虑将Unmarshal, ApplyFlags, ApplyEnvs 当做独立的函数,然后通过更上层的函数合并起来?

flags.go Outdated
./cmd -array="[\"a1\", \"a2\"]"
*/

var flagMap map[string]struct{} = nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flagMap 能否省掉? 比如直接查询FlagSet?

@shafreeck
Copy link
Collaborator

最好翻译为英文, 可以寻求下@xuehuaying 的协助

@xuehuaying
Copy link

这个pr需要我帮助吗?

@jl2005
Copy link
Author

jl2005 commented Jul 23, 2019

这个pr需要我帮助吗?

先等确认版本的,确认之后再翻译,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants