about summary refs log tree commit diff
path: root/Completion/Unix/Command/_python
diff options
context:
space:
mode:
authorJun T <takimoto-j@kba.biglobe.ne.jp>2014-07-04 00:59:13 +0900
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2014-07-03 22:55:42 +0100
commitd13c6dc44168ed4c0e71497ec2bbb752600a9e53 (patch)
treee4bc839b3f74121cc1e97cd7726d6720982ca39d /Completion/Unix/Command/_python
parentc8e5be9d0fbbc6fb1cf06175b7c3d4757f6d973c (diff)
downloadzsh-d13c6dc44168ed4c0e71497ec2bbb752600a9e53.tar.gz
zsh-d13c6dc44168ed4c0e71497ec2bbb752600a9e53.tar.xz
zsh-d13c6dc44168ed4c0e71497ec2bbb752600a9e53.zip
32833: complete Python and Ruby arguments as for Perl
Diffstat (limited to 'Completion/Unix/Command/_python')
-rw-r--r--Completion/Unix/Command/_python33
1 files changed, 22 insertions, 11 deletions
diff --git a/Completion/Unix/Command/_python b/Completion/Unix/Command/_python
index edc49b72b..da84b30b5 100644
--- a/Completion/Unix/Command/_python
+++ b/Completion/Unix/Command/_python
@@ -24,12 +24,12 @@ fi
 
 _arguments -C -s -S "$args[@]" \
   "-B[don't write .py\[co\] files on import]" \
-  '(1 -)-c+[program passed in as string (terminates option list)]:python command:' \
+  '(-)-c+[program passed in as string (terminates option list)]:python command:' \
   '-d[debug output from parser]' \
   '-E[ignore PYTHON* environment variables (such as PYTHONPATH)]' \
   '(1 * -)-h[display help information]' \
   '-i[inspect interactively after running script]' \
-  '(1 * -)-m[run library module as a script (terminates option list)]:module:->modules' \
+  '(-)-m[run library module as a script (terminates option list)]:module:->modules' \
   '-O[optimize generated bytecode slightly]' \
   '-OO[remove doc-strings in addition to the -O optimizations]' \
   "-s[don't add user site directory to sys.path]" \
@@ -39,16 +39,27 @@ _arguments -C -s -S "$args[@]" \
   '(1 * -)-V[display version information]' \
   '-W+[warning control]:warning filter (action\:message\:category\:module\:lineno):(default always ignore module once error)' \
   '-x[skip first line of source, allowing use of non-Unix forms of #!cmd]' \
-  '(-)1:script file:_files -g "*.py(|c|o)(-.)"' \
+  '(-)1:script_or_arg:->script_or_arg' \
   '*::script argument: _normal' && return
 
-if [[ "$state" = modules ]]; then
-  local -a modules
-  modules=(
-    ${${=${(f)"$(_call_program modules $words[1] -c \
-      'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)}
-  )
-  _wanted modules expl module compadd -a modules && return
-fi
+case "$state" in
+  modules)
+    local -a modules
+    modules=(
+      ${${=${(f)"$(_call_program modules $words[1] -c \
+        'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)}
+    )
+    _wanted modules expl module compadd -a modules && return
+    ;;
+  script_or_arg)
+    if [[ -n "$opt_args[(I)-(c|m)]" ]]; then
+      _description arg expl 'file'
+      _files "$expl[@]" && return
+    else
+      _description script expl 'Python script'
+      _files "$expl[@]" -g "*.py(|c|o)(-.)" && return
+    fi
+    ;;
+esac
 
 return 1