diff --git a/libbeat/cfgfile/cfgfile.go b/libbeat/cfgfile/cfgfile.go index 3ccaf684d38c..5320622ec282 100644 --- a/libbeat/cfgfile/cfgfile.go +++ b/libbeat/cfgfile/cfgfile.go @@ -14,7 +14,7 @@ var ( // The default config cannot include the beat name as it is not initialized // when this variable is created. See ChangeDefaultCfgfileFlag which should // be called prior to flags.Parse(). - configfiles = flagArgList("c", "beat.yml", "Configuration file") + configfiles = flagArgList("c", "beat.yml", "Configuration file `path`") overwrites = common.NewFlagConfig(nil, nil, "E", "Configuration overwrite") testConfig = flag.Bool("configtest", false, "Test configuration and exit.") diff --git a/libbeat/cfgfile/flags.go b/libbeat/cfgfile/flags.go index 8976dbf21c02..9daa2e657014 100644 --- a/libbeat/cfgfile/flags.go +++ b/libbeat/cfgfile/flags.go @@ -8,6 +8,7 @@ import ( type argList struct { list []string isDefault bool + f *flag.Flag } func flagArgList(name string, def string, usage string) *argList { @@ -16,10 +17,15 @@ func flagArgList(name string, def string, usage string) *argList { isDefault: true, } flag.Var(l, name, usage) + l.f = flag.Lookup(name) + if l.f == nil { + panic("Failed to lookup registered flag") + } return l } func (l *argList) SetDefault(v string) { + l.f.DefValue = v l.list = []string{v} l.isDefault = true }