aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/cmd.go4
-rw-r--r--cmd/completions/atlas.zsh113
-rw-r--r--cmd/query.go2
3 files changed, 114 insertions, 5 deletions
diff --git a/cmd/cmd.go b/cmd/cmd.go
index 5a4f942..086ebe1 100644
--- a/cmd/cmd.go
+++ b/cmd/cmd.go
@@ -37,8 +37,8 @@ func SetupGlobalFlags(fs_ *flag.FlagSet, flags *GlobalFlags) {
flag.StringVar(&flags.IndexRoot, "root", xdg.UserDirs.Documents, "root `directory` for indexing")
flag.StringVar(&flags.DBPath, "db", dataHome+string(os.PathSeparator)+"default.db", "`path` to document database")
flag.StringVar(&flags.LogLevel, "logLevel", "error", "set log `level` (debug, info, warn, error)")
- flag.BoolVar(&flags.LogJson, "logJson", false, "log to json")
+ flag.BoolVar(&flags.LogJson, "logJson", false, "output log information as json")
flag.UintVar(&flags.NumWorkers, "numWorkers", uint(runtime.NumCPU()), "number of worker threads to use (defaults to core count)")
flag.StringVar(&flags.DateFormat, "dateFormat", time.RFC3339, "`format` for dates (see https://pkg.go.dev/time#Layout for more details)")
- flag.StringVar(&flags.LogFile, "logFile", "", "`file` to log errors to, use '-' for stdout and empty for stderr")
+ flag.StringVar(&flags.LogFile, "logFile", "", "`file` to log errors to, use '-' for stdout and do not set a value for stderr")
}
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
+}
diff --git a/cmd/query.go b/cmd/query.go
index 7178c0d..f0834ba 100644
--- a/cmd/query.go
+++ b/cmd/query.go
@@ -53,7 +53,7 @@ func NewQueryFlagSet(flags *QueryFlags, dateFormat string) *flag.FlagSet {
fs.StringVar(&flags.SortBy, "sortBy", "", "category to sort by (path,title,date,filetime,meta)")
fs.BoolVar(&flags.SortDesc, "sortDesc", false, "sort in descending order")
- fs.StringVar(&flags.CustomFormat, "outCustomFormat", query.DefaultOutputFormat, "`format` string for --outFormat custom, see `atlas help query` for more details")
+ fs.StringVar(&flags.CustomFormat, "outCustomFormat", query.DefaultOutputFormat, "`format` string for -outFormat custom, see `atlas help query` for more details")
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")