diff --git a/app.go b/app.go index 63bc9cc..f51908c 100644 --- a/app.go +++ b/app.go @@ -1,6 +1,7 @@ package writefreely import ( + "flag" "fmt" _ "github.com/go-sql-driver/mysql" "net/http" @@ -28,6 +29,17 @@ type app struct { var shttp = http.NewServeMux() func Serve() { + createConfig := flag.Bool("create-config", false, "Creates a basic configuration and exits") + flag.Parse() + + if *createConfig { + log.Info("Creating configuration...") + c := config.New() + log.Info("Saving configuration...") + config.Save(c) + os.Exit(0) + } + log.Info("Initializing...") log.Info("Loading configuration...") diff --git a/config/config.go b/config/config.go index 8dff369..9defa9e 100644 --- a/config/config.go +++ b/config/config.go @@ -51,6 +51,7 @@ func New() *Config { Database: DatabaseCfg{ Type: "mysql", Host: "localhost", + Port: 3306, }, App: AppCfg{ Federation: true,