diff options
| -rw-r--r-- | cmd/completions/atlas.zsh | 1 | ||||
| -rw-r--r-- | cmd/query.go | 6 | ||||
| -rw-r--r-- | makefile | 15 |
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) @@ -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) ######## # |
