aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-12-08 02:16:04 +0100
committerPřemysl Eric Janouch <p@janouch.name>2023-12-08 02:16:04 +0100
commit941022bdd6c69de93f38992205b02ed95c6e8eb0 (patch)
tree510bfd9df7725e0e81b29ca0feb610dc986c37dd /main.go
downloadgallery-941022bdd6c69de93f38992205b02ed95c6e8eb0.tar.gz
gallery-941022bdd6c69de93f38992205b02ed95c6e8eb0.tar.xz
gallery-941022bdd6c69de93f38992205b02ed95c6e8eb0.zip
Initial commit
Diffstat (limited to 'main.go')
-rw-r--r--main.go82
1 files changed, 82 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..240f245
--- /dev/null
+++ b/main.go
@@ -0,0 +1,82 @@
+package main
+
+import (
+ "database/sql"
+ "log"
+ "os"
+
+ _ "github.com/mattn/go-sqlite3"
+)
+
+// init GD - initialize a "gallery directory" that contains gallery.sqlite,
+// images, thumbs.
+func cmdInit(args []string) {
+ if len(args) != 1 {
+ log.Fatalln("usage: GD")
+ }
+
+ gd := args[0]
+
+ db, err := sql.Open("sqlite3", gd+"/foo.db")
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ // TODO: Figure out a go generate to create a Go file to create the db.
+ _ = db
+}
+
+// run GD ADDRESS - run a web UI against GD on ADDRESS
+func cmdRun(args []string) {
+ // TODO: Use "public" from CWD for files.
+}
+
+// import GD ROOT... - add files to the "entry" table
+func cmdImport(args []string) {
+ // TODO
+}
+
+// sync GD ROOT... - like import, but clear table beforehands
+func cmdSync(args []string) {
+ // TODO
+}
+
+// check GD - see if all files are accessible
+func cmdCheck(args []string) {
+ // TODO
+}
+
+// thumbnail GD [SHA1...] - generate missing thumbnails, in parallel
+func cmdThumbnail(args []string) {
+ // TODO: Show progress.
+}
+
+// dhash GD HASHER [SHA1...] - generate perceptual hash from thumbnails
+func cmdDhash(args []string) {
+ // TODO
+}
+
+var commands = map[string]struct {
+ handler func(args []string)
+}{
+ "init": {cmdInit},
+ "run": {cmdRun},
+ "import": {cmdImport},
+ "sync": {cmdSync},
+ "check": {cmdCheck},
+ "thumbnail": {cmdThumbnail},
+ "dhash": {cmdDhash},
+}
+
+func main() {
+ if len(os.Args) <= 2 {
+ log.Fatalln("Missing arguments")
+ }
+
+ cmd, ok := commands[os.Args[1]]
+ if !ok {
+ log.Fatalln("Unknown command: " + os.Args[1])
+ }
+
+ cmd.handler(os.Args[2:])
+}