浏览代码

Add file completion as optional argument

Andrew Dwyer 9 年之前
父节点
当前提交
2449e41248
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      plugins/n98-magerun/n98-magerun.plugin.zsh

+ 10 - 2
plugins/n98-magerun/n98-magerun.plugin.zsh

@@ -7,11 +7,19 @@
 
 # n98-magerun basic command completion
 _n98_magerun_get_command_list () {
-  n98-magerun.phar --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z\-:]+/ { print $1 }'
+  $_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z\-:]+/ { print $1 }'
 }
 
+
 _n98_magerun () {
-  compadd `_n98_magerun_get_command_list`
+  _arguments '1: :->command' '*:optional arg:_files'
+
+  case $state in
+    command)
+      compadd $(_n98_magerun_get_command_list)
+      ;;
+    *)
+  esac
 }
 
 compdef _n98_magerun n98-magerun.phar