Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] completion: update base64, btrfs, emulate, tree



* base64 -- update for darwin/freebsd/netbsd
* btrfs -- fix specs for options with optargs
* emulate -- complete -l and -L, etc
* tree -- improve wording, complete new options

dana


diff --git a/Completion/Linux/Command/_btrfs b/Completion/Linux/Command/_btrfs
index d8b97a200..539416321 100644
--- a/Completion/Linux/Command/_btrfs
+++ b/Completion/Linux/Command/_btrfs
@@ -155,9 +155,9 @@ while (( $#state )); do
             '-c-[compress files while defragmenting]::compression algorithm:(zlib lzo zstd)'
             '-r[defragment files recursively]'
             '-f[flush after defragmenting]'
-            '-s[start position]: :_numbers -u bytes -d "beginning of file" offset K M G T P E'
-            '-l[defragment limited number of bytes]: :_numbers -u bytes length K M G T P E'
-            '-t[defragment only extents up to a certain size]: :_numbers -u bytes -d 32M "maximum extent size" K M G T P E'
+            '-s+[start position]: :_numbers -u bytes -d "beginning of file" offset K M G T P E'
+            '-l+[defragment limited number of bytes]: :_numbers -u bytes length K M G T P E'
+            '-t+[defragment only extents up to a certain size]: :_numbers -u bytes -d 32M "maximum extent size" K M G T P E'
             '*:file:_files'
           )
         ;;
@@ -213,8 +213,8 @@ while (( $#state )); do
             '-d[print separate statistics for each device]'
             '-r[read only mode]'
             '-R[raw print mode]'
-            '-c[set ioprio class]:class:(( 0\:none 1\:realtime 2\:best-effort 3\:idle))'
-            '-n[set ioprio classdata]:classdata:(0 1 2 3 4 5 6 7)'
+            '-c+[set ioprio class]:class:(( 0\:none 1\:realtime 2\:best-effort 3\:idle))'
+            '-n+[set ioprio classdata]:classdata:(0 1 2 3 4 5 6 7)'
             '1:path or device:_files'
           )
           [[ ${${(P)group}[cmd]} == start ]] && args+=(
@@ -246,7 +246,7 @@ while (( $#state )); do
         property:get) args+=( '2:property:(ro label compression)' );&
         property:list)
           args+=(
-            '-t[specify object type]:object type:(subvol filesystem inode device)'
+            '-t+[specify object type]:object type:(subvol filesystem inode device)'
             '1: : _guard "^-*" object'
           )
         ;;
diff --git a/Completion/Unix/Command/_base64 b/Completion/Unix/Command/_base64
index bbf100acb..6309d8022 100644
--- a/Completion/Unix/Command/_base64
+++ b/Completion/Unix/Command/_base64
@@ -8,7 +8,12 @@
 local variant type=base${service//[^2346]/}
 
 _pick_variant -r variant \
-  gnu='(Free Soft|uutils)' fourmilab=fourmi darwin=-D unix --version
+  gnu='(Free Soft|uutils)' freebsd=FreeBSD netbsd='<wrap>' fourmilab=fourmi unix --version
+
+# as of macOS 13, Apple's base64 is based on FreeBSD's, and it reports that way,
+# but it's moderately customised so that it supports roughly the same options as
+# the base64 shell script they provided previously
+[[ $variant == (freebsd|unix) && $OSTYPE == darwin* ]] && variant=darwin
 
 case $variant in
   gnu)
@@ -27,17 +32,42 @@ case $variant in
   darwin)
     _arguments -s -S : \
       '(: -)'{-h,--help}'[display help information]' \
+      '(: -)--version[display version information]' \
       + '(dec)' \
-      '(enc)'{-D,--decode}"[decode input from $type]" \
+      '(enc)'{-d,-D,--decode}"[decode input from $type]" \
       + '(enc)' \
-      '(dec)'{-b+,--break=}'[wrap encoded lines at specified number of columns]:number of columns' \
+      '(dec)'{-b+,-w+,--break=,--wrap=}'[wrap encoded lines at specified number of columns]:number of columns' \
+      '!(dec)--breaks=:number of columns' \
       + '(out)' \
       {-o+,--output=}'[specify output file]:output file:_files' \
       + '(in)' \
-      {-i+,--input=}'[specify input file]:input file:_files' \
+      {-i+,--input=}'[specify input file]:input file:_files'
+    return
+    ;;
+  freebsd)
+    _arguments -s -S -A '-*' : \
+      '(: -)--help[display help information]' \
+      '(: -)--version[display version information]' \
+      + dec \
+      '(enc -d --decode)'{-d,--decode}"[decode input from $type]" \
+      '!(enc)'{-i,--ignore-garbage} \
+      + '(enc)' \
+      '(dec)'{-w+,--wrap=}'[wrap encoded lines at specified number of columns]:number of columns' \
+      + in \
       '1:input file:_files'
     return
     ;;
+  netbsd)
+    _arguments -s -S -A '-*' : \
+      + dec \
+      '(enc -d -D)'{-d,-D}"[decode input from $type]" \
+      '(enc)-i[ignore irrelevant characters when decoding]' \
+      + '(enc)' \
+      '(dec)'{-b+,-w+}'[wrap encoded lines at specified number of columns]:number of columns' \
+      + in \
+      '*:input file:_files'
+    return
+    ;;
   fourmilab)
     _arguments -s -S : \
       '(: -)--copyright[display copyright information]' \
diff --git a/Completion/Unix/Command/_tree b/Completion/Unix/Command/_tree
index 595249126..fdb22a9c9 100644
--- a/Completion/Unix/Command/_tree
+++ b/Completion/Unix/Command/_tree
@@ -1,22 +1,29 @@
 #compdef tree
 
+# tree has its own weird option-parsing method that requires arguments to short
+# options to appear in the next word... except for -L (as of 2.2.1)
 _arguments -s -S \
   '-a[show all files, including hidden ones]' \
   '-d[list directories only]' \
   '-l[follow symlinks that point to directories]' \
   '-f[print full path prefix for each file]' \
   '-x[stay on current filesystem]' \
-  '-L[specify max tree depth to descend]:level' \
+  '-L+[specify max tree depth to descend]: :_numbers -l1 depth' \
   '-R[recursively cross down the tree and execute tree again]' \
-  '-P[only list files matching a pattern]:pattern:_files' \
-  "-I[don't list files matching a pattern]:pattern:_files" \
+  '-P[only list files matching specified pattern]:pattern:_files' \
+  "-I[don't list files matching specified pattern]:pattern:_files" \
+  '--gitignore[respect .gitignore files for filtering]' \
+  '*--gitfile=[use specified file as gitignore file]:gitignore file:_files' \
   '--ignore-case[ignore case when pattern matching]' \
   '--matchdirs[include directory names in -P pattern matching]' \
+  '--metafirst[print file meta-data at beginning of line]' \
+  '--info[print file comments found in .info files]' \
+  '*--infofile=[use specified file as info file]:info file:_files' \
   '--noreport[omit file and directory report at end]' \
-  '--charset=[character set for HTML and for line drawing]:charset' \
-  "--filelimit=[don't descend directories with more than specified number of entries]:entries" \
-  '--timefmt=[use specified time format]:format:_date_formats' \
-  '-o[output to specified file]:file:_files' \
+  '--charset=[specify character set for HTML and line drawing]:charset' \
+  "--filelimit=[don't descend directories with more than specified number of entries]: :_numbers entries" \
+  '--timefmt=[use specified time format]: :_date_formats' \
+  '-o[output to specified file]: :_files' \
   '--du[print directory sizes]' \
   '--prune[exclude empty directories from the output]' \
   '(-N)-q[print non-printable characters as question mark, not caret]' \
@@ -32,24 +39,33 @@ _arguments -s -S \
   '-F[append descriptive character to end, like ls -F]' \
   '--inodes[print inode numbers]' \
   '--device[print device number to which file or directory belongs]' \
-  '(--sort -t -c -U)-v[sort the output as version]' \
+  '(--sort -t -c -U)-v[sort output as version]' \
   '(-v --sort -c -U)-t[sort output by modification time]' \
   '(-v --sort -t -U)-c[sort output by change time]' \
   '(-v --sort -t -c -r --dirsfirst)-U[leave files unsorted]' \
   '(-U)-r[sort in reversed order]' \
-  '(-v -t -c -U)--sort[sort in specified order]:order:(name version size mtime ctime)' \
-  '(-U)--dirsfirst[list directories before files]' \
+  '(-v -t -c -U)--sort=[sort in specified order]:order:(name version size mtime ctime none)' \
+  '(-U --filesfirst)--dirsfirst[list directories before files]' \
+  '(-U --dirsfirst)--filesfirst[list files before directories]' \
   "-i[don't print indentation lines]" \
-  '(-S -X)-A[use ANSI line graphics hack when printing indentation lines]' \
-  '(-A -X)-S[use console (CP437) line graphics]' \
-  '(-C)-n[turn colorization off always, over-ridden by the -C option]' \
+  '(-S -H -J -X)-A[use ANSI line graphics hack when printing indentation lines]' \
+  '(-A)-S[equivalent to --charset=IBM437]' \
+  '(-C)-n[turn colorization off always]' \
   '(-n)-C[turn colorization on always]' \
-  '(-A -S -n -C -J -H -T --nolinks)-X[XML output]' \
-  '(-A -S -n -C -X -H -T --nolinks)-J[JSON output]' \
-  '(-n -C -X)-H[turn on HTML output]:base HREF' \
-  '(-n -C -X)-T[title for HTML output]:title' \
-  '(-n -C -X)--nolinks[turn off hyperlinks in HTML output]' \
-  '--fromfile[read paths from specified files]' \
-  '(-)--version[version of tree]' \
-  '(-)--help[verbose usage listing]' \
-  '*:directory:_files -/'
+  '(-A -J -H -T --nolinks)-X[turn on XML output]' \
+  '(-A -X -H -T --nolinks)-J[turn on JSON output]' \
+  '(-A -J -X)-H[turn on HTML output]:base HREF' \
+  '(-A -J -X)--hintro=[use specified file as HTML intro]:HTML intro file:_files' \
+  '(-A -J -X)--houtro=[use specified file as HTML outro]:HTML outro file:_files' \
+  '(-A -J -X)-T[specify title for HTML output]:title' \
+  '(-A -J -X --hyperlink)--nolinks[turn off hyperlinks in HTML output]' \
+  '(-H -J -X --nolinks)--hyperlink[turn on OSC 8 hyperlinks]' \
+  '(-H -J -X --nolinks)--scheme=[specify schema used for OSC 8 hyperlinks]:schema [file\://]' \
+  '(-H -J -X --nolinks)--authority=[specify authority (host name) used for OSC 8 hyperlinks]: :_hosts' \
+  '(--fromtabfile)--fromfile[read paths from specified files]:paths file:_files' \
+  '(--fromfile)--fromtabfile[read tab-indented paths from specified files]:paths file:_files' \
+  '--fflinks[process symbolic link information with in files (with --from*file)]' \
+  '--opt-toggle[turn on option toggling]' \
+  '(- :)--version[display version information]' \
+  '(- :)--help[display help information]' \
+  '*: :_directories'
diff --git a/Completion/Zsh/Command/_emulate b/Completion/Zsh/Command/_emulate
index d6fb0c3d9..a16738cdb 100644
--- a/Completion/Zsh/Command/_emulate
+++ b/Completion/Zsh/Command/_emulate
@@ -1,8 +1,9 @@
 #compdef emulate
 
-_arguments -C -s \
-  '-L[set local_options and local_traps as well]' \
+_arguments -s -S -A '-*' : \
+  '(2 3)-l[list options to be set or unset]' \
+  '(2 3)-L[set local_options and local_traps as well]' \
   '-R[reset all options instead of only those needed for script portability]' \
   '1:shell to emulate:(zsh sh ksh csh)' \
-  '2:specify optional command:(-c)' \
-  '3:command:_cmdstring'
+  '(-l -L)2:specify optional command:(-c)' \
+  '(-l -L)3: :_cmdstring'




Messages sorted by: Reverse Date, Date, Thread, Author