aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2026-09-23 12:27:28 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2026-09-23 12:27:28 -0400
commit848b082605fafa27b61f61aa6cec759014ad283a (patch)
tree4652a8e420f830646095da58ab91b46e1af772d5
parent422d3fa685f822138704d4985fda3d892c2dbdab (diff)
Add dry run flag; Update makefileHEADmain
-rw-r--r--cmd/completions/atlas.zsh1
-rw-r--r--cmd/query.go6
-rw-r--r--makefile15
3 files changed, 18 insertions, 4 deletions
diff --git a/cmd/completions/atlas.zsh b/cmd/completions/atlas.zsh
index 747047f..c232455 100644
--- a/cmd/completions/atlas.zsh
+++ b/cmd/completions/atlas.zsh
@@ -42,6 +42,7 @@ _atlas() {
_atlas_query() {
_arguments \
+ '-dry[parse query for errors but do not execute]' \
'-outFormat[output format for queries]:format:(default json yaml pathonly custom)' \
'-sortBy[category to sort by]:sortCriteria:(path title date filetime meta)' \
'-sortDesc[sort in descending order]' \
diff --git a/cmd/query.go b/cmd/query.go
index f0834ba..ae36465 100644
--- a/cmd/query.go
+++ b/cmd/query.go
@@ -20,6 +20,7 @@ type QueryFlags struct {
OptimizationLevel int
SortBy string
SortDesc bool
+ DryRun bool
}
func NewQueryFlagSet(flags *QueryFlags, dateFormat string) *flag.FlagSet {
@@ -57,6 +58,7 @@ func NewQueryFlagSet(flags *QueryFlags, dateFormat string) *flag.FlagSet {
fs.IntVar(&flags.OptimizationLevel, "optLevel", 0, "optimization `level` for queries, 0 is automatic, <0 to disable")
fs.StringVar(&flags.DocumentSeparator, "docSeparator", "\n", "separator for custom output format")
fs.StringVar(&flags.ListSeparator, "listSeparator", ", ", "separator for list fields")
+ fs.BoolVar(&flags.DryRun, "dry", false, "parse query for errors but do not execute")
fs.Usage = func() {
w := fs.Output()
@@ -77,6 +79,10 @@ func RunQuery(gFlags GlobalFlags, qFlags QueryFlags, db *data.Query, searchQuery
return 1
}
+ if qFlags.DryRun {
+ return 0
+ }
+
o := query.NewOptimizer(clause, gFlags.NumWorkers)
o.Optimize(qFlags.OptimizationLevel)
diff --git a/makefile b/makefile
index 5af28d0..273f1f1 100644
--- a/makefile
+++ b/makefile
@@ -1,13 +1,15 @@
BINS := atlas
BUILD_TAGS := icu fts5
SRC := main.go $(wildcard cmd/*.go) $(wildcard pkg/*/*.go)
+EMBEDDED_FILES := $(wildcard cmd/completions/*)
INSTALL_PATH := ~/.local/bin
+COMPLETION_PATHS := ~/.config/zsh/completions/_atlas
.PHONY: all install uninstall test info clean
all: $(BINS)
-atlas: $(SRC)
+atlas: $(SRC) $(EMBEDDED_FILES)
go build -tags "$(BUILD_TAGS)" -o $@ $<
test:
@@ -17,13 +19,18 @@ test:
#
########
-install: $(INSTALL_PATH)/atlas
+install: $(INSTALL_PATH)/atlas $(COMPLETION_PATHS)
$(INSTALL_PATH)/atlas: atlas
cp atlas $(INSTALL_PATH)
-uninstall: $(INSTALL_PATH)/atlas
- rm $<
+~/.config/zsh/completions/_atlas: atlas
+ mkdir -p $(dir $@)
+ $< completions zsh > $@
+
+uninstall:
+ rm -f $(INSTALL_PATH)/atlas
+ rm -f $(COMPLETION_PATHS)
########
#