m: add CfgSource and use it in all current cmds

This commit is contained in:
Brian Picciano 2018-08-13 21:09:20 -04:00
parent 132c51eaf0
commit 7f0b8056d7
2 changed files with 10 additions and 1 deletions

View File

@ -104,7 +104,7 @@ func main() {
}) })
mhttp.CfgServer(cfg, authHandler) mhttp.CfgServer(cfg, authHandler)
if err := cfg.StartRun(context.Background(), new(mcfg.SourceCLI)); err != nil { if err := cfg.StartRun(context.Background(), m.CfgSource()); err != nil {
mlog.Fatal("error during startup", mlog.ErrKV(err)) mlog.Fatal("error during startup", mlog.ErrKV(err))
} }
select {} select {}

9
m/m.go
View File

@ -11,6 +11,15 @@ import (
"github.com/mediocregopher/mediocre-go-lib/mlog" "github.com/mediocregopher/mediocre-go-lib/mlog"
) )
// CfgSource returns an mcfg.Source which takes in configuration info from the
// environment and from the CLI.
func CfgSource() mcfg.Source {
return mcfg.Sources{
mcfg.SourceEnv{},
mcfg.SourceCLI{},
}
}
// TODO this isn't going to work. At some point there will be something like // TODO this isn't going to work. At some point there will be something like
// mhttp which will have some glue code for it in here, but then something // mhttp which will have some glue code for it in here, but then something
// within it which logs (like the http server), and then there'll be an import // within it which logs (like the http server), and then there'll be an import