From 9d955119f23879b2ca45dab51063ecf3dd56eee4 Mon Sep 17 00:00:00 2001 From: gutmet Date: Wed, 23 Nov 2022 20:56:05 +0100 Subject: [PATCH] ignore boosts option for timline command --- go.mod | 2 +- go.sum | 4 ++-- swill.go | 18 +++++++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index d877c03..99c4357 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module git.gutmet.org/swill.git go 1.16 require ( - git.gutmet.org/go-mastodon.git v0.0.0-20221121192555-9585b1ce2e3b + git.gutmet.org/go-mastodon.git v0.0.0-20221123195156-1cc330baf3e9 git.gutmet.org/goutil.git v0.0.0-20201108182825-c19893df11f9 ) diff --git a/go.sum b/go.sum index aef9a28..87bba47 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -git.gutmet.org/go-mastodon.git v0.0.0-20221121192555-9585b1ce2e3b h1:hrafneYyLpduomEizAU5FmfVCdwNz077iXm6h9IkQBM= -git.gutmet.org/go-mastodon.git v0.0.0-20221121192555-9585b1ce2e3b/go.mod h1:e/Z3dytr4MYC4rdOjbWEbWXS+zy1CWxjvplVGTE/eH8= +git.gutmet.org/go-mastodon.git v0.0.0-20221123195156-1cc330baf3e9 h1:Jnyy69NDSxIBdfSnUExm89WpQhpUy1V584mr2DPsvNY= +git.gutmet.org/go-mastodon.git v0.0.0-20221123195156-1cc330baf3e9/go.mod h1:e/Z3dytr4MYC4rdOjbWEbWXS+zy1CWxjvplVGTE/eH8= git.gutmet.org/goutil.git v0.0.0-20201108182825-c19893df11f9 h1:XVD037Slgdl/CxcCWVtN6V+LzYl6QrTQ0upVIVpy6VE= git.gutmet.org/goutil.git v0.0.0-20201108182825-c19893df11f9/go.mod h1:iMgpxo9FxmbnUiQu5ugpjdtVZmh2rA9nySCr/GHkA64= git.gutmet.org/linkheader.git v0.0.0-20221120205136-a51e89fd8486 h1:7F1dwJvIgvHNvglosyIE7SA49BwG6b8DFkvD8NtHMD8= diff --git a/swill.go b/swill.go index eaa6c60..eccd984 100644 --- a/swill.go +++ b/swill.go @@ -279,17 +279,29 @@ func statusCommand() (goutil.CommandFlagsInit, goutil.CommandFunc) { return flagsInit, func(args []string) error { return status(f, args) } } -func userTimeline(args []string) error { +type timelineFlags struct { + ignoreBoosts bool +} + +func userTimeline(f timelineFlags, args []string) error { checkUsage(args, 1, 1, "timeline USER") user := args[0] account, err := mastodon.LookupAccount(user) optLogFatal("userTimeline - lookup account", err) - statuses, err := account.GetStatuses(nil) + statuses, err := account.GetStatuses(f.ignoreBoosts, nil) optLogFatal("userTimeline - get statuses", err) PrintStatuses(statuses) return nil } +func userTimelineCommand() (goutil.CommandFlagsInit, goutil.CommandFunc) { + f := timelineFlags{} + flagsInit := func(s *flag.FlagSet) { + s.BoolVar(&f.ignoreBoosts, "ignore-boosts", false, "") + } + return flagsInit, func(args []string) error { return userTimeline(f, args) } +} + type generalFlags struct { templateFile string } @@ -329,7 +341,7 @@ func main() { initializeMastodon() commands := []goutil.Command{ goutil.NewCommandWithFlags("status", wrapCommandFl(statusCommand), "post a status with message and/or media"), - goutil.NewCommandWithFlags("timeline", wrapCommand(userTimeline), "get timeline of a specific user"), + goutil.NewCommandWithFlags("timeline", wrapCommandFl(userTimelineCommand), "get latest timeline of a specific user"), } _ = goutil.Execute(commands) }