3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +01:00

oragono: add --quiet flag

This commit is contained in:
Daniel Oaks 2016-09-19 22:30:45 +10:00
parent 5d7d510348
commit dc0f679723

View File

@ -20,15 +20,16 @@ func main() {
version := irc.SEM_VER version := irc.SEM_VER
usage := `oragono. usage := `oragono.
Usage: Usage:
oragono initdb [--conf <filename>] oragono initdb [--conf <filename>] [--quiet]
oragono upgradedb [--conf <filename>] oragono upgradedb [--conf <filename>] [--quiet]
oragono genpasswd [--conf <filename>] oragono genpasswd [--conf <filename>] [--quiet]
oragono mkcerts [--conf <filename>] oragono mkcerts [--conf <filename>] [--quiet]
oragono run [--conf <filename>] oragono run [--conf <filename>] [--quiet]
oragono -h | --help oragono -h | --help
oragono --version oragono --version
Options: Options:
--conf <filename> Configuration file to use [default: ircd.yaml]. --conf <filename> Configuration file to use [default: ircd.yaml].
--quiet Don't show startup/shutdown lines.
-h --help Show this screen. -h --help Show this screen.
--version Show version.` --version Show version.`
@ -55,19 +56,27 @@ Options:
fmt.Println(encoded) fmt.Println(encoded)
} else if arguments["initdb"].(bool) { } else if arguments["initdb"].(bool) {
irc.InitDB(config.Datastore.Path) irc.InitDB(config.Datastore.Path)
log.Println("database initialized: ", config.Datastore.Path) if !arguments["--quiet"].(bool) {
log.Println("database initialized: ", config.Datastore.Path)
}
} else if arguments["upgradedb"].(bool) { } else if arguments["upgradedb"].(bool) {
irc.UpgradeDB(config.Datastore.Path) irc.UpgradeDB(config.Datastore.Path)
log.Println("database upgraded: ", config.Datastore.Path) if !arguments["--quiet"].(bool) {
log.Println("database upgraded: ", config.Datastore.Path)
}
} else if arguments["mkcerts"].(bool) { } else if arguments["mkcerts"].(bool) {
log.Println("making self-signed certificates") if !arguments["--quiet"].(bool) {
log.Println("making self-signed certificates")
}
for name, conf := range config.Server.TLSListeners { for name, conf := range config.Server.TLSListeners {
log.Printf(" making cert for %s listener\n", name) log.Printf(" making cert for %s listener\n", name)
host := config.Server.Name host := config.Server.Name
err := mkcerts.CreateCert("Oragono", host, conf.Cert, conf.Key) err := mkcerts.CreateCert("Oragono", host, conf.Cert, conf.Key)
if err == nil { if err == nil {
log.Printf(" Certificate created at %s : %s\n", conf.Cert, conf.Key) if !arguments["--quiet"].(bool) {
log.Printf(" Certificate created at %s : %s\n", conf.Cert, conf.Key)
}
} else { } else {
log.Fatal(" Could not create certificate:", err.Error()) log.Fatal(" Could not create certificate:", err.Error())
} }
@ -75,8 +84,10 @@ Options:
} else if arguments["run"].(bool) { } else if arguments["run"].(bool) {
irc.Log.SetLevel(config.Server.Log) irc.Log.SetLevel(config.Server.Log)
server := irc.NewServer(config) server := irc.NewServer(config)
log.Println(irc.SEM_VER, "running") if !arguments["--quiet"].(bool) {
defer log.Println(irc.SEM_VER, "exiting") log.Println(irc.SEM_VER, "running")
defer log.Println(irc.SEM_VER, "exiting")
}
server.Run() server.Run()
} }
} }