aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorRanXom <saiyedshizain@gmail.com>2026-07-13 20:00:01 +0530
committerRanXom <saiyedshizain@gmail.com>2026-07-13 20:00:01 +0530
commit424d138dd25c3f3cd7ce3f9e0d41aac19fe9cba8 (patch)
tree26dc9a77dadd55b8e2d3cf60cad16a87a36bb357 /cmd
parent778ec3e2e34b1a914e32109e8e02bdbf3dfc536a (diff)
downloadgalleryd-424d138dd25c3f3cd7ce3f9e0d41aac19fe9cba8.tar.xz
galleryd-424d138dd25c3f3cd7ce3f9e0d41aac19fe9cba8.zip
feat(cli): support multiple gallery directories
Diffstat (limited to 'cmd')
-rw-r--r--cmd/galleryd/flags.go15
-rw-r--r--cmd/galleryd/main.go25
2 files changed, 36 insertions, 4 deletions
diff --git a/cmd/galleryd/flags.go b/cmd/galleryd/flags.go
new file mode 100644
index 0000000..d3240d7
--- /dev/null
+++ b/cmd/galleryd/flags.go
@@ -0,0 +1,15 @@
+package main
+
+import "strings"
+
+// stringSliceFlag collects repeated string flags.
+type stringSliceFlag []string
+
+func (f *stringSliceFlag) String() string {
+ return strings.Join(*f, ",")
+}
+
+func (f *stringSliceFlag) Set(value string) error {
+ *f = append(*f, value)
+ return nil
+}
diff --git a/cmd/galleryd/main.go b/cmd/galleryd/main.go
index 319b6b6..f1643c5 100644
--- a/cmd/galleryd/main.go
+++ b/cmd/galleryd/main.go
@@ -18,10 +18,29 @@ import (
)
func main() {
- addr := flag.String("addr", ":8082", "HTTP listen address")
+ addr := flag.String(
+ "addr",
+ ":8082",
+ "HTTP listen address",
+ )
+
+ var dirs stringSliceFlag
+
+ flag.Var(
+ &dirs,
+ "dir",
+ "gallery directory (may be specified multiple times)",
+ )
flag.Parse()
+ if len(dirs) == 0 {
+ dirs = append(
+ dirs,
+ filepath.Join(os.Getenv("HOME"), "Pictures"),
+ )
+ }
+
ctx, stop := signal.NotifyContext(
context.Background(),
os.Interrupt,
@@ -30,9 +49,7 @@ func main() {
defer stop()
scanner := scanner.New(scanner.Config{
- Roots: []string{
- filepath.Join(os.Getenv("HOME"), "Pictures"),
- },
+ Roots: dirs,
})
reader := metadata.New()