summaryrefslogtreecommitdiff
path: root/srv/src/cmd/mailinglist-cli/main.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-07 13:17:18 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-07 13:18:44 -0600
commita10a604018d0cb07babfe218d9fb2e00e1c8ae3b (patch)
tree8d701b7350baee5fd619dfa35d1ac31a82fc2ce9 /srv/src/cmd/mailinglist-cli/main.go
parentc99b37c5b37d8944522eb73288581ca99670b660 (diff)
Refactor how data dir is initialized
Diffstat (limited to 'srv/src/cmd/mailinglist-cli/main.go')
-rw-r--r--srv/src/cmd/mailinglist-cli/main.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/srv/src/cmd/mailinglist-cli/main.go b/srv/src/cmd/mailinglist-cli/main.go
index c3207df..c090f41 100644
--- a/srv/src/cmd/mailinglist-cli/main.go
+++ b/srv/src/cmd/mailinglist-cli/main.go
@@ -4,9 +4,9 @@ import (
"context"
"errors"
"io"
- "path"
"github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
+ cfgpkg "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
"github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
@@ -17,11 +17,12 @@ func main() {
ctx := context.Background()
- cfg := cfg.New(cfg.Params{
- EnvPrefix: "MEDIOCRE_BLOG",
- })
+ cfg := cfgpkg.NewBlogCfg(cfg.Params{})
- dataDir := cfg.String("data-dir", ".", "Directory to use for long term storage")
+ var dataDir cfgpkg.DataDir
+ dataDir.SetupCfg(cfg)
+ defer dataDir.Close()
+ ctx = mctx.WithAnnotator(ctx, &dataDir)
var mailerParams mailinglist.MailerParams
mailerParams.SetupCfg(cfg)
@@ -54,10 +55,7 @@ func main() {
mailer = mailinglist.NewMailer(mailerParams)
}
- mailingListDBFile := path.Join(*dataDir, "mailinglist.sqlite3")
- ctx = mctx.Annotate(ctx, "mailingListDBFile", mailingListDBFile)
-
- mlStore, err := mailinglist.NewStore(mailingListDBFile)
+ mlStore, err := mailinglist.NewStore(dataDir)
if err != nil {
logger.Fatal(ctx, "initializing mailing list storage", err)
}