summaryrefslogtreecommitdiff
path: root/args
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-04-21 18:46:40 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-04-21 18:46:40 -0700
commitd14605d1388aaa7cc9ef1c230eae5ba14c9cef44 (patch)
tree59fcda0fae7899ca577eed1f72d89bff17d5ad5d /args
downloadbackup-notify-d14605d1388aaa7cc9ef1c230eae5ba14c9cef44.tar.gz
backup-notify-d14605d1388aaa7cc9ef1c230eae5ba14c9cef44.zip
initial commit
Diffstat (limited to 'args')
-rw-r--r--args/args.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/args/args.go b/args/args.go
new file mode 100644
index 0000000..dd080cb
--- /dev/null
+++ b/args/args.go
@@ -0,0 +1,52 @@
+package args
+
+import (
+ "flag"
+ "strings"
+)
+
+type Arguments struct {
+ DatabasePath string
+ TemplatePath string
+ StaticPath string
+
+ Migrate bool
+ Scheduler bool
+
+ NtfyEndpoint string
+ NtfyTopics []string
+
+ Port int
+ Server bool
+}
+
+func GetArgs() (*Arguments, error) {
+ databasePath := flag.String("database-path", "./backupnotify.db", "Path to the SQLite database")
+
+ templatePath := flag.String("template-path", "./templates", "Path to the template directory")
+ staticPath := flag.String("static-path", "./static", "Path to the static directory")
+
+ scheduler := flag.Bool("scheduler", false, "Run scheduled jobs via cron")
+ migrate := flag.Bool("migrate", false, "Run the migrations")
+ ntfyEndpoint := flag.String("ntfy-endpoint", "https://ntfy.sh", "")
+ ntfyTopics := flag.String("ntfy-topics", "server-backup", "")
+
+ port := flag.Int("port", 8080, "Port to listen on")
+ server := flag.Bool("server", false, "Run the server")
+
+ flag.Parse()
+
+ arguments := &Arguments{
+ DatabasePath: *databasePath,
+ TemplatePath: *templatePath,
+ StaticPath: *staticPath,
+ Port: *port,
+ Server: *server,
+ Migrate: *migrate,
+ Scheduler: *scheduler,
+ NtfyEndpoint: *ntfyEndpoint,
+ NtfyTopics: strings.Split(*ntfyTopics, ","),
+ }
+
+ return arguments, nil
+}