update zsh completions
This commit is contained in:
parent
372465e71c
commit
e1c040707e
5 changed files with 1748 additions and 142 deletions
|
@ -1,4 +1,5 @@
|
||||||
#compdef chezmoi
|
#compdef chezmoi
|
||||||
|
compdef _chezmoi chezmoi
|
||||||
|
|
||||||
# zsh completion for chezmoi -*- shell-script -*-
|
# zsh completion for chezmoi -*- shell-script -*-
|
||||||
|
|
||||||
|
@ -17,8 +18,9 @@ _chezmoi()
|
||||||
local shellCompDirectiveNoFileComp=4
|
local shellCompDirectiveNoFileComp=4
|
||||||
local shellCompDirectiveFilterFileExt=8
|
local shellCompDirectiveFilterFileExt=8
|
||||||
local shellCompDirectiveFilterDirs=16
|
local shellCompDirectiveFilterDirs=16
|
||||||
|
local shellCompDirectiveKeepOrder=32
|
||||||
|
|
||||||
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace
|
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
||||||
local -a completions
|
local -a completions
|
||||||
|
|
||||||
__chezmoi_debug "\n========= starting completion logic =========="
|
__chezmoi_debug "\n========= starting completion logic =========="
|
||||||
|
@ -136,6 +138,11 @@ _chezmoi()
|
||||||
noSpace="-S ''"
|
noSpace="-S ''"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
||||||
|
__chezmoi_debug "Activating keep order."
|
||||||
|
keepOrder="-V"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
||||||
# File extension filtering
|
# File extension filtering
|
||||||
local filteringCmd
|
local filteringCmd
|
||||||
|
@ -171,7 +178,7 @@ _chezmoi()
|
||||||
return $result
|
return $result
|
||||||
else
|
else
|
||||||
__chezmoi_debug "Calling _describe"
|
__chezmoi_debug "Calling _describe"
|
||||||
if eval _describe "completions" completions $flagPrefix $noSpace; then
|
if eval _describe $keepOrder "completions" completions $flagPrefix $noSpace; then
|
||||||
__chezmoi_debug "_describe found some completions"
|
__chezmoi_debug "_describe found some completions"
|
||||||
|
|
||||||
# Return the success of having called _describe
|
# Return the success of having called _describe
|
||||||
|
|
|
@ -43,7 +43,7 @@ _pdm() {
|
||||||
|
|
||||||
_arguments -s -C -A '-*' \
|
_arguments -s -C -A '-*' \
|
||||||
$arguments \
|
$arguments \
|
||||||
{-c,--config}'[Specify another config file path(env var: PDM_CONFIG_FILE)]' \
|
{-c,--config}'[Specify another config file path\[env var: PDM_CONFIG_FILE\]]' \
|
||||||
{-V,--version}'[Show the version and exit]' \
|
{-V,--version}'[Show the version and exit]' \
|
||||||
{-I,--ignore-python}'[Ignore the Python path saved in .pdm-python]' \
|
{-I,--ignore-python}'[Ignore the Python path saved in .pdm-python]' \
|
||||||
'--pep582:Print the command line to be eval by the shell:shell:(zsh bash fish tcsh csh)' \
|
'--pep582:Print the command line to be eval by the shell:shell:(zsh bash fish tcsh csh)' \
|
||||||
|
@ -70,15 +70,17 @@ _pdm() {
|
||||||
'--save-exact[Save exact version specifiers]'
|
'--save-exact[Save exact version specifiers]'
|
||||||
'--save-minimum[Save minimum version specifiers]'
|
'--save-minimum[Save minimum version specifiers]'
|
||||||
'--update-reuse[Reuse pinned versions already present in lock file if possible]'
|
'--update-reuse[Reuse pinned versions already present in lock file if possible]'
|
||||||
|
'--update-reuse-installed[Reuse installed packages if possible]'
|
||||||
'--update-eager[Try to update the packages and their dependencies recursively]'
|
'--update-eager[Try to update the packages and their dependencies recursively]'
|
||||||
'--update-all[Update all dependencies and sub-dependencies]'
|
'--update-all[Update all dependencies and sub-dependencies]'
|
||||||
'--no-editable[Install non-editable versions for all packages]'
|
'--no-editable[Install non-editable versions for all packages]'
|
||||||
"--no-self[Don't install the project itself]"
|
"--no-self[Don't install the project itself]"
|
||||||
"--no-lock[Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]]"
|
"--frozen-lockfile[Don't try to create or update the lockfile. \[env var: PDM_FROZEN_LOCKFILE\]]"
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:'
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:'
|
||||||
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
||||||
{-u,--unconstrained}'[Ignore the version constraint of packages]'
|
{-u,--unconstrained}'[Ignore the version constraint of packages]'
|
||||||
{--pre,--prerelease}'[Allow prereleases to be pinned]'
|
{--pre,--prerelease}'[Allow prereleases to be pinned]'
|
||||||
|
"--stable[Only allow stable versions to be pinned]"
|
||||||
{-e+,--editable+}'[Specify editable packages]:packages'
|
{-e+,--editable+}'[Specify editable packages]:packages'
|
||||||
{-x,--fail-fast}'[Abort on first installation error]'
|
{-x,--fail-fast}'[Abort on first installation error]'
|
||||||
"--no-isolation[do not isolate the build in a clean environment]"
|
"--no-isolation[do not isolate the build in a clean environment]"
|
||||||
|
@ -147,8 +149,11 @@ _pdm() {
|
||||||
arguments+=(
|
arguments+=(
|
||||||
{-g,--global}'[Use the global project, supply the project root with `-p` option]'
|
{-g,--global}'[Use the global project, supply the project root with `-p` option]'
|
||||||
{-f+,--format+}"[Specify the export file format]:format:(pipfile poetry flit requirements setuppy)"
|
{-f+,--format+}"[Specify the export file format]:format:(pipfile poetry flit requirements setuppy)"
|
||||||
"--without-hashes[Don't include artifact hashes]"
|
"--no-hashes[Don't include artifact hashes]"
|
||||||
|
"--no-markers[Don't include platform markers]"
|
||||||
"--expandvars[Expand environment variables in requirements]"
|
"--expandvars[Expand environment variables in requirements]"
|
||||||
|
"--self[Include the project itself]"
|
||||||
|
"--editable-self[Include the project itself as an editable dependency]"
|
||||||
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
||||||
{-o+,--output+}"[Write output to the given file, or print to stdout if not given]:output file:_files"
|
{-o+,--output+}"[Write output to the given file, or print to stdout if not given]:output file:_files"
|
||||||
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups'
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups'
|
||||||
|
@ -179,7 +184,7 @@ _pdm() {
|
||||||
'--env[Show PEP 508 environment markers]'
|
'--env[Show PEP 508 environment markers]'
|
||||||
'--packages[Show the packages root]'
|
'--packages[Show the packages root]'
|
||||||
'--json[Dump the information in JSON]'
|
'--json[Dump the information in JSON]'
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:'
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
init)
|
init)
|
||||||
|
@ -188,8 +193,8 @@ _pdm() {
|
||||||
{-n,--non-interactive}"[Don't ask questions but use default values]"
|
{-n,--non-interactive}"[Don't ask questions but use default values]"
|
||||||
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
||||||
{-r,--overwrite}'[Overwrite existing files]'
|
{-r,--overwrite}'[Overwrite existing files]'
|
||||||
'--backend[Specify the build backend]:backend:(pdm-backend setuptools hatchling flit)'
|
'--backend[Specify the build backend, which implies --dist]:backend:(pdm-backend setuptools hatchling flit)'
|
||||||
'--lib[Create a library project]'
|
{--dist,--lib}'[Create a package for distribution]'
|
||||||
'--python[Specify the Python version/path to use]:python:'
|
'--python[Specify the Python version/path to use]:python:'
|
||||||
'--copier[Use Copier to generate project]'
|
'--copier[Use Copier to generate project]'
|
||||||
'--cookiecutter[Use Cookiecutter to generate project]'
|
'--cookiecutter[Use Cookiecutter to generate project]'
|
||||||
|
@ -204,7 +209,7 @@ _pdm() {
|
||||||
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
||||||
{--prod,--production}"[Unselect dev dependencies]"
|
{--prod,--production}"[Unselect dev dependencies]"
|
||||||
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
||||||
"--no-lock[Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]]"
|
"--frozen-lockfile[Don't try to create or update the lockfile. \[env var: PDM_FROZEN_LOCKFILE\]]"
|
||||||
"--no-default[Don\'t include dependencies from the default group]"
|
"--no-default[Don\'t include dependencies from the default group]"
|
||||||
'--no-editable[Install non-editable versions for all packages]'
|
'--no-editable[Install non-editable versions for all packages]'
|
||||||
"--no-self[Don't install the project itself]"
|
"--no-self[Don't install the project itself]"
|
||||||
|
@ -213,7 +218,7 @@ _pdm() {
|
||||||
"--dry-run[Show the difference only without modifying the lock file content]"
|
"--dry-run[Show the difference only without modifying the lock file content]"
|
||||||
"--check[Check if the lock file is up to date and fail otherwise]"
|
"--check[Check if the lock file is up to date and fail otherwise]"
|
||||||
"--plugins[Install the plugins specified in pyproject.toml]"
|
"--plugins[Install the plugins specified in pyproject.toml]"
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:'
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
list)
|
list)
|
||||||
|
@ -230,7 +235,7 @@ _pdm() {
|
||||||
"--include[Dependency groups to include in the output. By default all are included]:include:"
|
"--include[Dependency groups to include in the output. By default all are included]:include:"
|
||||||
"--exclude[Dependency groups to exclude from the output]:exclude:"
|
"--exclude[Dependency groups to exclude from the output]:exclude:"
|
||||||
"--resolve[Resolve all requirements to output licenses (instead of just showing those currently installed)]"
|
"--resolve[Resolve all requirements to output licenses (instead of just showing those currently installed)]"
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:'
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:'
|
||||||
'*:patterns:'
|
'*:patterns:'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
|
@ -245,11 +250,13 @@ _pdm() {
|
||||||
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups'
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups'
|
||||||
{-d,--dev}"[Select dev dependencies]"
|
{-d,--dev}"[Select dev dependencies]"
|
||||||
{--prod,--production}"[Unselect dev dependencies]"
|
{--prod,--production}"[Unselect dev dependencies]"
|
||||||
|
'--update-reuse[Reuse pinned versions already present in lock file if possible]'
|
||||||
|
'--update-reuse-installed[Reuse installed packages if possible]'
|
||||||
"--static-urls[(DEPRECATED) Store static file URLs in the lockfile]"
|
"--static-urls[(DEPRECATED) Store static file URLs in the lockfile]"
|
||||||
"--no-static-urls[(DEPRECATED) Do not store static file URLs in the lockfile]"
|
"--no-static-urls[(DEPRECATED) Do not store static file URLs in the lockfile]"
|
||||||
"--no-default[Don\'t include dependencies from the default group]"
|
"--no-default[Don\'t include dependencies from the default group]"
|
||||||
"--no-cross-platform[(DEPRECATED) Only lock packages for the current platform]"
|
"--no-cross-platform[(DEPRECATED) Only lock packages for the current platform]"
|
||||||
{-S,--strategy}'Specify lock strategy(cross_platform,static_urls,direct_minimal_versions). Add no_ prefix to disable. Support given multiple times or split by comma.:strategy:'
|
{-S,--strategy}'[Specify lock strategy(cross_platform,static_urls,direct_minimal_versions). Add no_ prefix to disable. Support given multiple times or split by comma.]:strategy:'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
self)
|
self)
|
||||||
|
@ -303,9 +310,9 @@ _pdm() {
|
||||||
;;
|
;;
|
||||||
publish)
|
publish)
|
||||||
arguments+=(
|
arguments+=(
|
||||||
{-r,--repository}'[The repository name or url to publish the package to }[env var: PDM_PUBLISH_REPO]]:repository:'
|
{-r,--repository}'[The repository name or url to publish the package to }\[env var: PDM_PUBLISH_REPO\]]:repository:'
|
||||||
{-u,--username}'[The username to access the repository [env var: PDM_PUBLISH_USERNAME]]:username:'
|
{-u,--username}'[The username to access the repository \[env var: PDM_PUBLISH_USERNAME\]]:username:'
|
||||||
{-P,--password}'[The password to access the repository [env var: PDM_PUBLISH_PASSWORD]]:password:'
|
{-P,--password}'[The password to access the repository \[env var: PDM_PUBLISH_PASSWORD\]]:password:'
|
||||||
{-S,--sign}'[Upload the package with PGP signature]'
|
{-S,--sign}'[Upload the package with PGP signature]'
|
||||||
{-i,--identity}'[GPG identity used to sign files.]:gpg identity:'
|
{-i,--identity}'[GPG identity used to sign files.]:gpg identity:'
|
||||||
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
||||||
|
@ -313,6 +320,7 @@ _pdm() {
|
||||||
"--no-verify-ssl[Disable SSL verification]"
|
"--no-verify-ssl[Disable SSL verification]"
|
||||||
"--ca-certs[The path to a PEM-encoded Certificate Authority bundle to use for publish server validation]:cacerts:_files"
|
"--ca-certs[The path to a PEM-encoded Certificate Authority bundle to use for publish server validation]:cacerts:_files"
|
||||||
"--no-build[Don't build the package before publishing]"
|
"--no-build[Don't build the package before publishing]"
|
||||||
|
"--skip-existing[Skip uploading files that already exist. This may not work with some repository implementations.]"
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
remove)
|
remove)
|
||||||
|
@ -325,11 +333,11 @@ _pdm() {
|
||||||
"--no-sync[Only write pyproject.toml and do not uninstall packages]"
|
"--no-sync[Only write pyproject.toml and do not uninstall packages]"
|
||||||
'--no-editable[Install non-editable versions for all packages]'
|
'--no-editable[Install non-editable versions for all packages]'
|
||||||
"--no-self[Don't install the project itself]"
|
"--no-self[Don't install the project itself]"
|
||||||
"--no-lock[Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]]"
|
"--frozen-lockfile[Don't try to create or update the lockfile. \[env var: PDM_FROZEN_LOCKFILE\]]"
|
||||||
{-x,--fail-fast}'[Abort on first installation error]'
|
{-x,--fail-fast}'[Abort on first installation error]'
|
||||||
"--no-isolation[do not isolate the build in a clean environment]"
|
"--no-isolation[do not isolate the build in a clean environment]"
|
||||||
"--dry-run[Show the difference only without modifying the lockfile content]"
|
"--dry-run[Show the difference only without modifying the lockfile content]"
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:'
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:'
|
||||||
"*:packages:_pdm_packages"
|
"*:packages:_pdm_packages"
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
|
@ -340,7 +348,7 @@ _pdm() {
|
||||||
'--json[Output all scripts infos in JSON]' \
|
'--json[Output all scripts infos in JSON]' \
|
||||||
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' \
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' \
|
||||||
{-s,--site-packages}'[Load site-packages from the selected interpreter]' \
|
{-s,--site-packages}'[Load site-packages from the selected interpreter]' \
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:' \
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:' \
|
||||||
'(-)1:command:->command' \
|
'(-)1:command:->command' \
|
||||||
'*:arguments: _normal ' && return 0
|
'*:arguments: _normal ' && return 0
|
||||||
if [[ $state == command ]]; then
|
if [[ $state == command ]]; then
|
||||||
|
@ -364,7 +372,7 @@ _pdm() {
|
||||||
'--license[Show license]'
|
'--license[Show license]'
|
||||||
'--platform[Show platform]'
|
'--platform[Show platform]'
|
||||||
'--keywords[Show keywords]'
|
'--keywords[Show keywords]'
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:'
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:'
|
||||||
'1:package:'
|
'1:package:'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
|
@ -385,7 +393,7 @@ _pdm() {
|
||||||
'--no-editable[Install non-editable versions for all packages]'
|
'--no-editable[Install non-editable versions for all packages]'
|
||||||
"--no-self[Don't install the project itself]"
|
"--no-self[Don't install the project itself]"
|
||||||
"--no-isolation[do not isolate the build in a clean environment]"
|
"--no-isolation[do not isolate the build in a clean environment]"
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:'
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
update)
|
update)
|
||||||
|
@ -400,13 +408,15 @@ _pdm() {
|
||||||
'--update-reuse[Reuse pinned versions already present in lock file if possible]'
|
'--update-reuse[Reuse pinned versions already present in lock file if possible]'
|
||||||
'--update-eager[Try to update the packages and their dependencies recursively]'
|
'--update-eager[Try to update the packages and their dependencies recursively]'
|
||||||
'--update-all[Update all dependencies and sub-dependencies]'
|
'--update-all[Update all dependencies and sub-dependencies]'
|
||||||
|
'--update-reuse-installed[Reuse installed packages if possible]'
|
||||||
'--no-editable[Install non-editable versions for all packages]'
|
'--no-editable[Install non-editable versions for all packages]'
|
||||||
"--no-self[Don't install the project itself]"
|
"--no-self[Don't install the project itself]"
|
||||||
"--no-sync[Only update lock file but do not sync packages]"
|
"--no-sync[Only update lock file but do not sync packages]"
|
||||||
"--no-lock[Don't try to create or update the lockfile. [env var: PDM_NO_LOCK]]"
|
"--frozen-lockfile[Don't try to create or update the lockfile. \[env var: PDM_FROZEN_LOCKFILE\]]"
|
||||||
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
||||||
{-u,--unconstrained}'[Ignore the version constraint of packages]'
|
{-u,--unconstrained}'[Ignore the version constraint of packages]'
|
||||||
{--pre,--prerelease}'[Allow prereleases to be pinned]'
|
{--pre,--prerelease}'[Allow prereleases to be pinned]'
|
||||||
|
"--stable[Only allow stable versions to be pinned]"
|
||||||
{-d,--dev}'[Select dev dependencies]'
|
{-d,--dev}'[Select dev dependencies]'
|
||||||
{--prod,--production}"[Unselect dev dependencies]"
|
{--prod,--production}"[Unselect dev dependencies]"
|
||||||
"--no-default[Don\'t include dependencies from the default group]"
|
"--no-default[Don\'t include dependencies from the default group]"
|
||||||
|
@ -415,7 +425,7 @@ _pdm() {
|
||||||
"--outdated[Show the difference only without modifying the lockfile content]"
|
"--outdated[Show the difference only without modifying the lockfile content]"
|
||||||
{-x,--fail-fast}'[Abort on first installation error]'
|
{-x,--fail-fast}'[Abort on first installation error]'
|
||||||
"--no-isolation[do not isolate the build in a clean environment]"
|
"--no-isolation[do not isolate the build in a clean environment]"
|
||||||
'--venv[Run the command in the virtual environment with the given key. (env var: PDM_IN_VENV)]:venv:'
|
'--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:'
|
||||||
"*:packages:_pdm_packages"
|
"*:packages:_pdm_packages"
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,4 @@
|
||||||
#compdef rclone
|
#compdef _rclone rclone
|
||||||
compdef _rclone rclone
|
|
||||||
|
|
||||||
# zsh completion for rclone -*- shell-script -*-
|
# zsh completion for rclone -*- shell-script -*-
|
||||||
|
|
||||||
|
@ -18,9 +17,8 @@ _rclone()
|
||||||
local shellCompDirectiveNoFileComp=4
|
local shellCompDirectiveNoFileComp=4
|
||||||
local shellCompDirectiveFilterFileExt=8
|
local shellCompDirectiveFilterFileExt=8
|
||||||
local shellCompDirectiveFilterDirs=16
|
local shellCompDirectiveFilterDirs=16
|
||||||
local shellCompDirectiveKeepOrder=32
|
|
||||||
|
|
||||||
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace
|
||||||
local -a completions
|
local -a completions
|
||||||
|
|
||||||
__rclone_debug "\n========= starting completion logic =========="
|
__rclone_debug "\n========= starting completion logic =========="
|
||||||
|
@ -88,24 +86,7 @@ _rclone()
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local activeHelpMarker="_activeHelp_ "
|
|
||||||
local endIndex=${#activeHelpMarker}
|
|
||||||
local startIndex=$((${#activeHelpMarker}+1))
|
|
||||||
local hasActiveHelp=0
|
|
||||||
while IFS='\n' read -r comp; do
|
while IFS='\n' read -r comp; do
|
||||||
# Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
|
|
||||||
if [ "${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
|
|
||||||
__rclone_debug "ActiveHelp found: $comp"
|
|
||||||
comp="${comp[$startIndex,-1]}"
|
|
||||||
if [ -n "$comp" ]; then
|
|
||||||
compadd -x "${comp}"
|
|
||||||
__rclone_debug "ActiveHelp will need delimiter"
|
|
||||||
hasActiveHelp=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$comp" ]; then
|
if [ -n "$comp" ]; then
|
||||||
# If requested, completions are returned with a description.
|
# If requested, completions are returned with a description.
|
||||||
# The description is preceded by a TAB character.
|
# The description is preceded by a TAB character.
|
||||||
|
@ -113,7 +94,7 @@ _rclone()
|
||||||
# We first need to escape any : as part of the completion itself.
|
# We first need to escape any : as part of the completion itself.
|
||||||
comp=${comp//:/\\:}
|
comp=${comp//:/\\:}
|
||||||
|
|
||||||
local tab="$(printf '\t')"
|
local tab=$(printf '\t')
|
||||||
comp=${comp//$tab/:}
|
comp=${comp//$tab/:}
|
||||||
|
|
||||||
__rclone_debug "Adding completion: ${comp}"
|
__rclone_debug "Adding completion: ${comp}"
|
||||||
|
@ -122,27 +103,11 @@ _rclone()
|
||||||
fi
|
fi
|
||||||
done < <(printf "%s\n" "${out[@]}")
|
done < <(printf "%s\n" "${out[@]}")
|
||||||
|
|
||||||
# Add a delimiter after the activeHelp statements, but only if:
|
|
||||||
# - there are completions following the activeHelp statements, or
|
|
||||||
# - file completion will be performed (so there will be choices after the activeHelp)
|
|
||||||
if [ $hasActiveHelp -eq 1 ]; then
|
|
||||||
if [ ${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
|
|
||||||
__rclone_debug "Adding activeHelp delimiter"
|
|
||||||
compadd -x "--"
|
|
||||||
hasActiveHelp=0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
|
||||||
__rclone_debug "Activating nospace."
|
__rclone_debug "Activating nospace."
|
||||||
noSpace="-S ''"
|
noSpace="-S ''"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
|
|
||||||
__rclone_debug "Activating keep order."
|
|
||||||
keepOrder="-V"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
|
||||||
# File extension filtering
|
# File extension filtering
|
||||||
local filteringCmd
|
local filteringCmd
|
||||||
|
@ -160,7 +125,7 @@ _rclone()
|
||||||
_arguments '*:filename:'"$filteringCmd"
|
_arguments '*:filename:'"$filteringCmd"
|
||||||
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
|
||||||
# File completion for directories only
|
# File completion for directories only
|
||||||
local subdir
|
local subDir
|
||||||
subdir="${completions[1]}"
|
subdir="${completions[1]}"
|
||||||
if [ -n "$subdir" ]; then
|
if [ -n "$subdir" ]; then
|
||||||
__rclone_debug "Listing directories in $subdir"
|
__rclone_debug "Listing directories in $subdir"
|
||||||
|
@ -178,7 +143,7 @@ _rclone()
|
||||||
return $result
|
return $result
|
||||||
else
|
else
|
||||||
__rclone_debug "Calling _describe"
|
__rclone_debug "Calling _describe"
|
||||||
if eval _describe $keepOrder "completions" completions $flagPrefix $noSpace; then
|
if eval _describe "completions" completions $flagPrefix $noSpace; then
|
||||||
__rclone_debug "_describe found some completions"
|
__rclone_debug "_describe found some completions"
|
||||||
|
|
||||||
# Return the success of having called _describe
|
# Return the success of having called _describe
|
||||||
|
|
|
@ -23,4 +23,4 @@ gen chezmoi completion zsh
|
||||||
gen rye self completion -s zsh
|
gen rye self completion -s zsh
|
||||||
gen gh completion -s zsh
|
gen gh completion -s zsh
|
||||||
gen pixi completion -s zsh
|
gen pixi completion -s zsh
|
||||||
gen rclone completion zsh -
|
gen rclone completion zsh
|
||||||
|
|
Loading…
Reference in a new issue