Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Make --new-config accept path from --config. Closes #410.

Kailash Nadh5e2c24b6620b
diff --git a/cmd/install.go b/cmd/install.go
index 58cf4af6..97c5831b 100644
--- a/cmd/install.go
+++ b/cmd/install.go
@@ -1,7 +1,6 @@
package main
import (
- "errors"
"fmt"
"io/ioutil"
"os"
@@ -161,9 +160,9 @@ func recordMigrationVersion(ver string, db *sqlx.DB) error {
return err
}
-func newConfigFile() error {
- if _, err := os.Stat("config.toml"); !os.IsNotExist(err) {
- return errors.New("config.toml exists. Remove it to generate a new one")
+func newConfigFile(path string) error {
+ if _, err := os.Stat(path); !os.IsNotExist(err) {
+ return fmt.Errorf("%s exists. Remove it to generate a new one.", path)
}
// Initialize the static file system into which all
@@ -181,7 +180,7 @@ func newConfigFile() error {
ReplaceAll(b, []byte(fmt.Sprintf(`admin_password = "%s"`, pwd)))
}
- return ioutil.WriteFile("config.toml", b, 0644)
+ return ioutil.WriteFile(path, b, 0644)
}
// checkSchema checks if the DB schema is installed.
diff --git a/cmd/main.go b/cmd/main.go
index a55684da..5ece04ed 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -85,11 +85,12 @@ func init() {
// Generate new config.
if ko.Bool("new-config") {
- if err := newConfigFile(); err != nil {
+ path := ko.Strings("config")[0]
+ if err := newConfigFile(path); err != nil {
lo.Println(err)
os.Exit(1)
}
- lo.Println("generated config.toml. Edit and run --install")
+ lo.Printf("generated %s. Edit and run --install", path)
os.Exit(0)
}