summary refs log tree commit diff
path: root/Completion/Unix/Command/_make
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2013-07-11 11:14:38 +0100
committerPeter Stephenson <pws@zsh.org>2013-07-11 11:14:38 +0100
commit7e17ea8016744fa7066d58eb008e30d3796f755d (patch)
treee1ab4b7f3d7c2df1b2c709055c7a125e7d23f3fd /Completion/Unix/Command/_make
parent669c070efe06d1820ccb32adaa6b1512279401ab (diff)
downloadzsh-7e17ea8016744fa7066d58eb008e30d3796f755d.tar.gz
zsh-7e17ea8016744fa7066d58eb008e30d3796f755d.tar.xz
zsh-7e17ea8016744fa7066d58eb008e30d3796f755d.zip
users/17856: rewrite _make to use _arguments.
No new option handling yet, but this should make it easier to add.
Diffstat (limited to 'Completion/Unix/Command/_make')
-rw-r--r--Completion/Unix/Command/_make44
1 files changed, 34 insertions, 10 deletions
diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index 53e2e1b3e..72d16bb7d 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -148,7 +148,9 @@ _make-findBasedir () {
 _make() {
 
   local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match
-  local -A TARGETS VARIABLES
+  local context state line
+  local -a option_specs
+  local -A TARGETS VARIABLES opt_args
   local ret=1
 
   _pick_variant -r is_gnu gnu=GNU unix -v -f
@@ -156,21 +158,43 @@ _make() {
   if [[ $is_gnu == gnu ]]
   then
     incl="(-|)include"
+    # TBD: update option_specs
+    option_specs=(
+      '-C[change directory first]:directory:->dir'
+      '-I[include directory for makefiles]:directory:->dir'
+      '-f[specify makefile]:makefile:->file'
+      '-o[specify file not to remake]:file not to remake:->file'
+      '-W[pretend file was modified]:file to treat as modified:->file'
+    )
   else
+    # Basic make options only.
     incl=.include
+    option_specs=(
+      '-C[change directory first]:directory:->dir'
+      '-I[include directory for makefiles]:directory:->dir'
+      '-f[specify makefile]:makefile:->file'
+      '-o[specify file not to remake]:file not to remake:->file'
+      '-W[pretend file was modified]:file to treat as modified:->file'
+    )
   fi
 
-  if [[ "$prev" == -[CI] ]]
-  then
+  _arguments -s $option_specs \
+    '*:make target:->target' && ret=0
+
+  case $state in
+    (dir)
     _files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0
-  elif [[ "$prev" == -[foW] ]]
-  then
+    ;;
+
+    (file)
     _files -W ${(q)$(_make-findBasedir $words)} && ret=0
-  else
-    file="$words[(I)-f]"
-    if (( file ))
+    ;;
+
+    (target)
+    file=($opt_args[(K)(-f|--file|--makefile)])
+    file=$file[1]
+    if [[ -n $file ]]
     then
-      file=${~words[file+1]}
       [[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file
       [[ -r $file ]] || file=
     else
@@ -222,7 +246,7 @@ _make() {
           compadd -S '=' -- ${(k)VARIABLES} && ret=0
       done
     fi
-  fi
+  esac
 
   return ret
 }