about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-05-20 23:07:25 +0200
committerAlan Pearce2024-05-20 23:07:25 +0200
commit9c790c1c620e46ca8d2cf49c50951635621e9a7d (patch)
tree5afd308fe2d94436eadabef2e36252e833a9e4ae
parentd90f62a74a667ec6dbb891df34f574d22983fabd (diff)
downloadsearchix-9c790c1c620e46ca8d2cf49c50951635621e9a7d.tar.lz
searchix-9c790c1c620e46ca8d2cf49c50951635621e9a7d.tar.zst
searchix-9c790c1c620e46ca8d2cf49c50951635621e9a7d.zip
feat: add --update flag to force-update index and exit
-rw-r--r--justfile3
-rw-r--r--searchix.go5
2 files changed, 6 insertions, 2 deletions
diff --git a/justfile b/justfile
index 87bc5ca..1295f29 100644
--- a/justfile
+++ b/justfile
@@ -25,3 +25,6 @@ dev:
 
 reindex:
 	wgo run --exit . --config config.toml --replace
+
+update:
+	wgo run --exit . --config config.toml --update
diff --git a/searchix.go b/searchix.go
index 384dfe7..e672bbf 100644
--- a/searchix.go
+++ b/searchix.go
@@ -31,6 +31,7 @@ var (
 	)
 	liveReload = flag.Bool("live", false, "whether to enable live reloading (development)")
 	replace    = flag.Bool("replace", false, "replace existing index and exit")
+	update     = flag.Bool("update", false, "update index and exit")
 	version    = flag.Bool("version", false, "print version information")
 )
 
@@ -111,13 +112,13 @@ func main() {
 		log.Fatalf("Failed to open or create index: %v", err)
 	}
 
-	if !exists || *replace {
+	if !exists || *replace || *update {
 		slog.Info("Index doesn't exist. Starting build job...")
 		err = importer.Start(cfg, write, *replace, nil)
 		if err != nil {
 			log.Fatalf("Failed to build index: %v", err)
 		}
-		if *replace {
+		if *replace || *update {
 			return
 		}
 	} else {