repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

pico / cmd / scripts / pico-plus
Eric Bower · 01 Mar 24

main.go

 1package main
 2
 3import (
 4	"log/slog"
 5	"os"
 6
 7	"github.com/picosh/pico/db/postgres"
 8)
 9
10func main() {
11	logger := slog.Default()
12	DbURL := os.Getenv("DATABASE_URL")
13	dbpool := postgres.NewDB(DbURL, logger)
14
15	args := os.Args
16	username := args[1]
17	paymentType := ""
18	if len(args) > 2 {
19		paymentType = args[2]
20	}
21	txId := ""
22	if len(args) > 3 {
23		txId = args[3]
24	}
25
26	logger.Info(
27		"Upgrading user to pico+",
28		"username", username,
29		"paymentType", paymentType,
30		"txId", txId,
31	)
32
33	err := dbpool.AddPicoPlusUser(username, paymentType, txId)
34	if err != nil {
35		logger.Error("Failed to add pico+ user", "err", err)
36		os.Exit(1)
37	} else {
38		logger.Info("Successfully added pico+ user")
39	}
40}