From 64687599ae2de65ab937f1b80571c12e4f74015f Mon Sep 17 00:00:00 2001 From: Pierre Ayoub Date: Wed, 26 Feb 2025 05:34:04 +0100 Subject: [PATCH] docs(git-bulk): Add zsh completion (#1190) * docs(git-bulk): Add zsh completion * docs(git-bulk): Harmonize help strings * docs(git-bulk): simplify previous bad logic The previous logic was not allowing to use multiple options (which is often the case). This was bad because this is my first time with zsh automcompletion. Without it, the user can use any flag combination -- but at least, he has the freedom. --- etc/git-extras-completion.zsh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index 05f271b..9e1c18d 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -92,6 +92,13 @@ __gitex_submodule_names() { _wanted submodule-names expl submodule-name compadd $* - $submodule_names } +__gitex_workspace_names() { + local expl + declare -a workspace_names + workspace_names=($(git bulk --listall | awk '{print $1}' | cut -d "." -f 2)) + __gitex_command_successful || return + _wanted workspace-names expl workspace-names compadd $* - $workspace_names +} __gitex_author_names() { local expl @@ -122,6 +129,20 @@ _git-brv() { '(-r --reverse)'{-r,--reverse}'[reverse order]' } +_git-bulk() { + _arguments \ + '-a[Run a git command on all workspaces and their repositories.]' \ + '-g[Ask the user for confirmation on every execution (guarded mode).]' \ + '-w[Run the git command on the specified workspace.]:workspace-name:__gitex_workspace_names' \ + '-q[Suppress bulk output about current execution (quiet mode).]' \ + '--addworkspace[Register a workspace for bulk operations.]' \ + '--removeworkspace[Remove the specified workspace.]:workspace-name:__gitex_workspace_names' \ + '--addcurrent[Adds the current directory as workspace to git bulk operations]' \ + '--purge[Removes all defined repository locations.]' \ + '--listall[List all registered repositories.]' \ + '--help[Show the help.]' +} + _git-changelog() { _arguments \ '(-l --list)'{-l,--list}'[list commits]' \