aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/completions/atlas.zsh
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2026-09-23 12:00:44 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2026-09-23 12:00:44 -0400
commit422d3fa685f822138704d4985fda3d892c2dbdab (patch)
treeb45ec591988289a2e82fafc295797599f2c879a7 /cmd/completions/atlas.zsh
parentb7b1cdc485f3022a04c4f87e54acdfdca7bf0bfb (diff)
Add zsh completions
Diffstat (limited to 'cmd/completions/atlas.zsh')
-rw-r--r--cmd/completions/atlas.zsh113
1 files changed, 111 insertions, 2 deletions
diff --git a/cmd/completions/atlas.zsh b/cmd/completions/atlas.zsh
index c9f45e0..747047f 100644
--- a/cmd/completions/atlas.zsh
+++ b/cmd/completions/atlas.zsh
@@ -2,6 +2,7 @@
_atlas() {
local -a commands
+
commands=(
'query:Query stuff'
'index:Index stuff'
@@ -11,7 +12,115 @@ _atlas() {
'help:View help'
)
- _describe 'command' commands
+ _arguments -C \
+ '-root[root directory for indexing]:directory:_directories' \
+ '-db[path to document database]:database:_files' \
+ '-logLevel[set log level]:level:(debug info warn error)' \
+ '-logJson[output log information as json]' \
+ '-numWorkers[number of worker threads to use (defaults to logical core count)]:count:' \
+ '-dateFormat[format for dates (see https://pkg.go.dev/time#Layout for more details)]' \
+ '-logFile[file to log errors to, use - for stdout and do not set a value for stderr]:logfile:_files' \
+ '1:command:->command' \
+ '*::arguments:->arguments'
+
+ case $state in
+ command)
+ _describe 'command' commands
+ ;;
+ arguments)
+ case $words[1] in
+ query) _atlas_query ;;
+ index) _atlas_index ;;
+ server) _atlas_server ;;
+ shell) _atlas_shell ;;
+ completions) _atlas_completions ;;
+ help) _atlas_help ;;
+ esac
+ esac
+}
+
+_atlas_query() {
+
+ _arguments \
+ '-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]' \
+ '-customFormat[format string for -outFormat custom, see `atlas help query` for more detials]:format:' \
+ '-optLevel[optimization level for queries, 0 is automatic, set to < 0 to disable optimizations]:level:' \
+ '-docSeparator[separator for custom output format]:separator:' \
+ '-listSeparator[separator for list fields]:separator:'
+
+ # TODO: encode langauge grammar for completions
+}
+
+_atlas_index() {
+ local -a commands filters
+ commands=(
+ 'build:Create or replace document index'
+ 'update:Update existing document index'
+ 'tidy:Cleanup document index, removing stale files'
+ )
+ filters=(
+ 'YAMLHeader'
+ 'Ext_'
+ 'Extension_'
+ 'MaxSize_'
+ 'MaxFilesize_'
+ 'ExcludeName_'
+ 'ExcludeFilename_'
+ 'IncludeName_'
+ 'IncludeFilename_'
+ 'ExcludeParent_'
+ 'IncludeRegex_'
+ 'ExcludeRegex_'
+ )
+
+ if (( CURRENT == 3)); then
+ _describe 'subcommand' commands
+ return
+ fi
+
+ # TODO: input validation for filters
+ _arguments \
+ '-ignoreBadDates[ignore malformed dates while indexing]' \
+ '-ignoreMetaError[ignore errors while parsing general YAML header info]' \
+ '-ignoreMeta[only parse title,authors,date, and tags from YAML headers]' \
+ '-ignoreHeadings[avoid parsing file contents for section headings]' \
+ '-ignoreHidden[ignore hidden files while crawling]' \
+ '-filter[accept or reject files from indexing, applied in supplied order (default Ex_.md, MaxSize_204800, YAMLHeader, ExcludeParent_templates)]:filter:'
+}
+
+_atlas_server() {
+ _arguments \
+ '-address[listening address, prefix with unix: to create a unix socket]:host:' \
+ '-port[port to bind to]:port:'
}
-_atlas "$@"
+_atlas_shell() {}
+
+_atlas_completions() {
+ (( CURRENT > 2)) && return
+
+ local -a shells
+ shells=(
+ 'zsh'
+ )
+ _describe 'shell' shells
+}
+
+_atlas_help() {
+ (( CURRENT > 2 )) && return
+ local -a topics
+ topics=(
+ 'index'
+ 'index build'
+ 'index update'
+ 'index tidy'
+ 'query'
+ 'shell'
+ 'server'
+ 'completions'
+ )
+
+ _describe 'help topic' topics
+}