summaryrefslogtreecommitdiff
path: root/srv/cmd
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2021-08-10 13:07:14 -0600
committerBrian Picciano <mediocregopher@gmail.com>2021-08-10 13:07:14 -0600
commitac5275353c0d0f33ebe47c3e177d0b35b7bd6581 (patch)
treee0828f25f072fbe41e5c79ae1e3a9c6bd588f0f3 /srv/cmd
parentca27cd6c677f5effe7b08639a8db92371065b4e3 (diff)
implement publish sub-cmd of mailinglist-cli
Diffstat (limited to 'srv/cmd')
-rw-r--r--srv/cmd/mailinglist-cli/main.go30
1 files changed, 22 insertions, 8 deletions
diff --git a/srv/cmd/mailinglist-cli/main.go b/srv/cmd/mailinglist-cli/main.go
index ca4ccd6..4ae47fe 100644
--- a/srv/cmd/mailinglist-cli/main.go
+++ b/srv/cmd/mailinglist-cli/main.go
@@ -68,14 +68,10 @@ func main() {
ml := mailinglist.New(mlParams)
_ = ml
- args := cfg.Args()
- if len(args) == 0 {
- args = append(args, "")
- }
-
- action, args := args[0], args[1:]
+ subCmd := cfg.SubCmd()
+ ctx = mctx.Annotate(ctx, "subCmd", subCmd)
- switch action {
+ switch subCmd {
case "list":
for it := mlStore.GetAll(); ; {
email, err := it()
@@ -94,7 +90,25 @@ func main() {
logger.Info(ctx, "next")
}
+ case "publish":
+
+ title := cfg.String("title", "", "Title of the post which was published")
+ url := cfg.String("url", "", "URL of the post which was published")
+ cfg.Init(ctx)
+
+ if *title == "" {
+ logger.Fatal(ctx, "-title is required")
+
+ } else if *url == "" {
+ logger.Fatal(ctx, "-url is required")
+ }
+
+ err := ml.Publish(*title, *url)
+ if err != nil {
+ loggerFatalErr(ctx, logger, "publishing", err)
+ }
+
default:
- logger.Fatal(ctx, "invalid action")
+ logger.Fatal(ctx, "invalid sub-command, must be list|publish")
}
}