Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Complete python module arguments
- X-seq: zsh-workers 53382
- From: Ronan Pigott <ronan@xxxxxx>
- To: zsh-workers@xxxxxxx
- Cc: Ronan Pigott <ronan@xxxxxx>
- Subject: [PATCH] Complete python module arguments
- Date: Tue, 25 Feb 2025 11:07:26 -0700
- Archived-at: <https://zsh.org/workers/53382>
- List-id: <zsh-workers.zsh.org>
Python modules can behave like commands in their own right. This allows
modules to define _python_module_* functions that are used to complete
module arguments. Also gets the ball rolling by defining completions for
venv, a commonly used python module.
---
Completion/Unix/Command/_python | 3 +++
Completion/Unix/Command/_python_module_venv | 10 ++++++++++
2 files changed, 13 insertions(+)
create mode 100644 Completion/Unix/Command/_python_module_venv
diff --git a/Completion/Unix/Command/_python b/Completion/Unix/Command/_python
index 6e209a1998d7..75a9d79a189d 100644
--- a/Completion/Unix/Command/_python
+++ b/Completion/Unix/Command/_python
@@ -56,6 +56,9 @@ case "$state" in
if [[ -z "$opt_args[(I)-(c|m)]" ]]; then
shift words
(( CURRENT-- ))
+ elif [[ -n "$opt_args[(I)-m]" ]]; then
+ local ret
+ _call_function ret _python_module_$opt_args[-m] && return ret
fi
_normal && return
;;
diff --git a/Completion/Unix/Command/_python_module_venv b/Completion/Unix/Command/_python_module_venv
new file mode 100644
index 000000000000..0ee78001f0b8
--- /dev/null
+++ b/Completion/Unix/Command/_python_module_venv
@@ -0,0 +1,10 @@
+#autoload
+
+_arguments -S \
+ '(--symlinks --copies)--symlinks[Try to use symlinks rather than copies]' \
+ '(--symlinks --copies)--copies[Try to use copies rather than symlinks]' \
+ '(--clear --upgrade)--clear[Delete the contents of the environment directory if it already exists]' \
+ '(--clear --upgrade)--upgrade[Upgrade the environment directory to use this version of Python]' \
+ '--without-pip[Skip installing or upgrading pip]' \
+ '--upgrade-deps[Upgrade core dependencies to the latest version]' \
+ '*::virtual environment'
--
2.48.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author