cmd/dendrite: Factor out string argument unwrapping to function

This commit is contained in:
Robert Swain 2017-04-21 14:21:27 +02:00
parent 2bbff202c4
commit 1949147d8f

View file

@ -21,6 +21,13 @@ import (
"github.com/docopt/docopt-go" "github.com/docopt/docopt-go"
) )
func maybeArgToStr(arg interface{}) string {
if arg != nil {
return arg.(string)
}
return ""
}
func main() { func main() {
usage := ` usage := `
Usage: Usage:
@ -67,11 +74,7 @@ Environment Variables:
args, _ := docopt.Parse(usage, nil, true, args, _ := docopt.Parse(usage, nil, true,
"dendrite Matrix homeserver, version 0.0.1", false) "dendrite Matrix homeserver, version 0.0.1", false)
logDirArg := args["--log-dir"] logDir := maybeArgToStr(args["--log-dir"])
logDir := ""
if logDirArg != nil {
logDir = logDirArg.(string)
}
common.SetupLogging(logDir) common.SetupLogging(logDir)
log.Infoln(args) log.Infoln(args)