mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 23:13:11 -06:00
cmd/dendrite: Factor out string argument unwrapping to function
This commit is contained in:
parent
2bbff202c4
commit
1949147d8f
|
|
@ -21,6 +21,13 @@ import (
|
|||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func maybeArgToStr(arg interface{}) string {
|
||||
if arg != nil {
|
||||
return arg.(string)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func main() {
|
||||
usage := `
|
||||
Usage:
|
||||
|
|
@ -67,11 +74,7 @@ Environment Variables:
|
|||
args, _ := docopt.Parse(usage, nil, true,
|
||||
"dendrite Matrix homeserver, version 0.0.1", false)
|
||||
|
||||
logDirArg := args["--log-dir"]
|
||||
logDir := ""
|
||||
if logDirArg != nil {
|
||||
logDir = logDirArg.(string)
|
||||
}
|
||||
logDir := maybeArgToStr(args["--log-dir"])
|
||||
common.SetupLogging(logDir)
|
||||
|
||||
log.Infoln(args)
|
||||
|
|
|
|||
Loading…
Reference in a new issue