From dc0f679723253e2260c87510969e9afdb8d0b459 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Mon, 19 Sep 2016 22:30:45 +1000 Subject: [PATCH] oragono: add --quiet flag --- oragono.go | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/oragono.go b/oragono.go index f6e57d7b..4151c794 100644 --- a/oragono.go +++ b/oragono.go @@ -20,15 +20,16 @@ func main() { version := irc.SEM_VER usage := `oragono. Usage: - oragono initdb [--conf ] - oragono upgradedb [--conf ] - oragono genpasswd [--conf ] - oragono mkcerts [--conf ] - oragono run [--conf ] + oragono initdb [--conf ] [--quiet] + oragono upgradedb [--conf ] [--quiet] + oragono genpasswd [--conf ] [--quiet] + oragono mkcerts [--conf ] [--quiet] + oragono run [--conf ] [--quiet] oragono -h | --help oragono --version Options: --conf Configuration file to use [default: ircd.yaml]. + --quiet Don't show startup/shutdown lines. -h --help Show this screen. --version Show version.` @@ -55,19 +56,27 @@ Options: fmt.Println(encoded) } else if arguments["initdb"].(bool) { 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) { 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) { - log.Println("making self-signed certificates") + if !arguments["--quiet"].(bool) { + log.Println("making self-signed certificates") + } for name, conf := range config.Server.TLSListeners { log.Printf(" making cert for %s listener\n", name) host := config.Server.Name err := mkcerts.CreateCert("Oragono", host, conf.Cert, conf.Key) 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 { log.Fatal(" Could not create certificate:", err.Error()) } @@ -75,8 +84,10 @@ Options: } else if arguments["run"].(bool) { irc.Log.SetLevel(config.Server.Log) server := irc.NewServer(config) - log.Println(irc.SEM_VER, "running") - defer log.Println(irc.SEM_VER, "exiting") + if !arguments["--quiet"].(bool) { + log.Println(irc.SEM_VER, "running") + defer log.Println(irc.SEM_VER, "exiting") + } server.Run() } }