summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-01-11 00:45:02 +0200
committerPaul Buetow <paul@buetow.org>2025-01-11 00:45:02 +0200
commit94d9b5f48147ee9cc6ca57177e00f8679224603d (patch)
treec3ae81b6c31c5deb0582fca475f156718a6dd380 /cmd
parent97b93252dfcb0242bb1cd5e3e5793a8ae73b17a9 (diff)
add gosc binary
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gos/main.go71
-rw-r--r--cmd/gosc/main.go9
2 files changed, 10 insertions, 70 deletions
diff --git a/cmd/gos/main.go b/cmd/gos/main.go
index 4e3ef68..f89b740 100644
--- a/cmd/gos/main.go
+++ b/cmd/gos/main.go
@@ -1,78 +1,9 @@
package main
import (
- "context"
- "flag"
- "fmt"
- "log"
- "os"
- "path/filepath"
- "strings"
- "time"
-
"codeberg.org/snonux/gos/internal"
- "codeberg.org/snonux/gos/internal/config"
)
-const versionStr = "v0.0.2"
-
func main() {
- dry := flag.Bool("dry", false, "Dry run")
- version := flag.Bool("version", false, "Display version")
- gosDir := flag.String("gosDir", filepath.Join(os.Getenv("HOME"), ".gosdir"), "Gos' queue and DB directory")
- cacheDir := flag.String("cacheDir", filepath.Join(*gosDir, "cache"), "Go's cache dir")
- browser := flag.String("browser", "firefox", "OAuth2 browser")
- secretsConfigPath := filepath.Join(os.Getenv("HOME"), ".config/gos/gosec.json")
- secretsConfigPath = *flag.String("secretsConfig", secretsConfigPath, "Gos' secret config")
- platforms := flag.String("platforms", "Mastodon:500,LinkedIn:1000", "Platforms enabled plus their post size limits")
- target := flag.Int("target", 2, "How many posts per week are the target?")
- minQueued := flag.Int("minQueued", 4, "Minimum of queued items until printing a warn message!")
- maxDaysQueued := flag.Int("maxDaysQueued", 365, "Maximum days worth of queued posts until target++ and pauseDays--")
- pauseDays := flag.Int("pauseDays", 3, "How many days until next post can be posted?")
- lookback := flag.Int("lookback", 30, "How many days look back in time for posting history")
- summaryFor := flag.String("summaryFor", "", "Generate a summary in Gemtext format, format is coma separated string of months, e.g. 202410,202411")
- gemtexterEnable := flag.Bool("gemtexterEnable", true, "Add special Gemtexter tags to the Gemtext summary")
- composeEntry := flag.Bool("compose", false, "Compose a new entry")
- flag.Parse()
-
- secrets, err := config.NewSecrets(secretsConfigPath)
- if err != nil {
- log.Fatal(err)
- }
-
- args := config.Args{
- DryRun: *dry,
- GosDir: *gosDir,
- Target: *target,
- MinQueued: *minQueued,
- MaxDaysQueued: *maxDaysQueued,
- PauseDays: *pauseDays,
- Lookback: time.Duration(*lookback) * time.Hour * 24,
- SecretsConfigPath: secretsConfigPath,
- CacheDir: *cacheDir,
- Secrets: secrets,
- OAuth2Browser: *browser,
- GemtexterEnable: *gemtexterEnable,
- ComposeEntry: *composeEntry,
- }
- if *summaryFor != "" {
- args.SummaryFor = strings.Split(*summaryFor, ",")
- }
-
- if err := args.ParsePlatforms(*platforms); err != nil {
- log.Fatal(err)
- }
-
- if *version {
- fmt.Printf("This is Gos version %s; (C) by Paul Buetow\n", versionStr)
- fmt.Println("https://codeberg.org/snonux/gos")
- return
- }
-
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
-
- if err := internal.Run(ctx, args); err != nil {
- log.Fatal(err)
- }
+ internal.Main(false)
}
diff --git a/cmd/gosc/main.go b/cmd/gosc/main.go
new file mode 100644
index 0000000..02eb0ae
--- /dev/null
+++ b/cmd/gosc/main.go
@@ -0,0 +1,9 @@
+package main
+
+import (
+ "codeberg.org/snonux/gos/internal"
+)
+
+func main() {
+ internal.Main(true)
+}