Fix altsrc nil source flag

This commit is contained in:
Aleksandr Kramarenko
2020-03-09 13:34:05 +03:00
parent d648edd48d
commit 32dd20a85b
4 changed files with 23 additions and 5 deletions

View File

@@ -87,8 +87,12 @@ func NewTomlSourceFromFile(file string) (InputSourceContext, error) {
// NewTomlSourceFromFlagFunc creates a new TOML InputSourceContext from a provided flag name and source context.
func NewTomlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) {
return func(context *cli.Context) (InputSourceContext, error) {
filePath := context.String(flagFileName)
return NewTomlSourceFromFile(filePath)
if context.IsSet(flagFileName) {
filePath := context.String(flagFileName)
return NewTomlSourceFromFile(filePath)
} else {
return defaultInputSource()
}
}
}