Avoid using global variables, use local variables instead
This commit is contained in:
parent
5d82a3e724
commit
3340a40f64
144
src/_conan
144
src/_conan
|
|
@ -39,7 +39,11 @@
|
|||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_conan_common_options=(
|
||||
_conan() {
|
||||
local context state state_descr line ret=1
|
||||
typeset -A opt_args
|
||||
|
||||
local -a conan_common_options=(
|
||||
'(- *)'{-h,--help}'[show help message and exit]'
|
||||
'-v[verbose output]'
|
||||
'-vquiet[verbose level quiet]'
|
||||
|
|
@ -56,24 +60,6 @@ _conan_common_options=(
|
|||
\*{-cc,--core-conf}'[define core configuration, overwriting global.conf values]:value'
|
||||
)
|
||||
|
||||
_conan_lockfile_options=(
|
||||
'(-l --lockfile)'{-l,--lockfile}'[path to a lockfile]: :_files'
|
||||
'--lockfile-partial[do not raise an error if some dependency is not found in lockfile]'
|
||||
'--lockfile-out[filename of the updated lockfile]: :_files'
|
||||
'--lockfile-clean[remove unused entries from the lockfile]'
|
||||
'*--lockfile-overrides[overwrite lockfile overrides]:overrides'
|
||||
)
|
||||
|
||||
_conan_remote_options=(
|
||||
'(-r --remote -nr --no-remote)'{-r,--remote}'[look in the specified remote server]:remote'
|
||||
'(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote, resolve exclusively in the cache]'
|
||||
\*{-u,--update}'[will install newer versions for the given references]:update'
|
||||
)
|
||||
|
||||
_conan() {
|
||||
local context state state_descr line ret=1
|
||||
typeset -A opt_args
|
||||
|
||||
local -a conan_reference_options=(
|
||||
'--name[provide a package name if not specified in conanfile]:name'
|
||||
'--version[provide a package version if not specified in conanfile]:version'
|
||||
|
|
@ -100,6 +86,20 @@ _conan() {
|
|||
'(-c\:a --conf\:all)'{-c\\:a,--conf\\:all}'[apply the specified conf all]:conf_all'
|
||||
)
|
||||
|
||||
local -a conan_lockfile_options=(
|
||||
'(-l --lockfile)'{-l,--lockfile}'[path to a lockfile]: :_files'
|
||||
'--lockfile-partial[do not raise an error if some dependency is not found in lockfile]'
|
||||
'--lockfile-out[filename of the updated lockfile]: :_files'
|
||||
'--lockfile-clean[remove unused entries from the lockfile]'
|
||||
'*--lockfile-overrides[overwrite lockfile overrides]:overrides'
|
||||
)
|
||||
|
||||
local -a conan_remote_options=(
|
||||
'(-r --remote -nr --no-remote)'{-r,--remote}'[look in the specified remote server]:remote'
|
||||
'(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote, resolve exclusively in the cache]'
|
||||
\*{-u,--update}'[will install newer versions for the given references]:update'
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'(- : *)'{-h,--help}'[display help information]' \
|
||||
'(- : *)'{-v,--version}'[display version information]' \
|
||||
|
|
@ -169,7 +169,7 @@ _conan_cache() {
|
|||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'1:subcommand:->subcommand' \
|
||||
'*:: :->args' \
|
||||
&& ret=0
|
||||
|
|
@ -190,7 +190,7 @@ _conan_cache() {
|
|||
_describe -t 'commands' "command" commands && ret=0
|
||||
;;
|
||||
(args)
|
||||
local -a opts=($_conan_common_options[@])
|
||||
local -a opts=($conan_common_options[@])
|
||||
case $words[1] in
|
||||
(check-integrity|sign|verify)
|
||||
opts+=(
|
||||
|
|
@ -270,7 +270,7 @@ _conan_config() {
|
|||
_describe -t 'commands' "command" commands && ret=0
|
||||
;;
|
||||
(args)
|
||||
local -a opts=($_conan_common_options[@])
|
||||
local -a opts=($conan_common_options[@])
|
||||
case $words[1] in
|
||||
(install)
|
||||
opts+=(
|
||||
|
|
@ -330,17 +330,17 @@ _conan_graph() {
|
|||
_describe -t 'commands' "command" commands && ret=0
|
||||
;;
|
||||
(args)
|
||||
local -a opts=($_conan_common_options[@])
|
||||
local -a opts=($conan_common_options[@])
|
||||
case $words[1] in
|
||||
(build-order|explain|info|outdated)
|
||||
opts+=(
|
||||
\*{-b,--build}'[optional, specify which packages to build from source]:build'
|
||||
'--requires[directly provide requires instead of a conanfile]:requires'
|
||||
'--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires'
|
||||
$_conan_remote_options[@]
|
||||
$conan_remote_options[@]
|
||||
$conan_profile_options[@]
|
||||
$conan_reference_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
'*:folder:_files -/'
|
||||
)
|
||||
;|
|
||||
|
|
@ -390,7 +390,7 @@ _conan_inspect() {
|
|||
local ret=1
|
||||
|
||||
_arguments \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'(-f --format)'{-f,--format}'[select the output format]:format:(json)' \
|
||||
'(-r --remote -nr --no-remote)'{-r,--remote}'[remote names. Accepts wildcards("*")]:remote' \
|
||||
'(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]' \
|
||||
|
|
@ -412,7 +412,7 @@ _conan_install() {
|
|||
virtualrunenv youcompleteme txt json premake make markdown deploy
|
||||
)
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
'(-f --format)'{-f,--format}'[select the output format]:format:(json)'
|
||||
\*{-b,--build}'[optional, specify which packages to build from source]:build'
|
||||
'--requires[directly provide requires instead of a conanfile]:requires'
|
||||
|
|
@ -424,9 +424,9 @@ _conan_install() {
|
|||
'*--deployer-packge[execute the deploy() method of the packages matching the provided patterns]:pattern'
|
||||
'--build-require[whether the provided path is a build-require]'
|
||||
'--envs-generation[generation strategy for virtual environment files for the root]:bool:(false)'
|
||||
$_conan_remote_options[@]
|
||||
$conan_remote_options[@]
|
||||
$conan_profile_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
'1:recipe_dir_or_conanfile:_files'
|
||||
)
|
||||
|
||||
|
|
@ -438,7 +438,7 @@ _conan_install() {
|
|||
_conan_list() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
'(-f --format)'{-f,--format}'[select the output format]:format:(json html compact)'
|
||||
\*{-p,--package-query}'[remove only the packages matching a specific query]:query'
|
||||
\*{-fp,--filter-profile}'[profiles to filter the binaries]:filter_profile'
|
||||
|
|
@ -482,7 +482,7 @@ _conan_lock() {
|
|||
_describe -t 'commands' "command" commands && ret=0
|
||||
;;
|
||||
(args)
|
||||
local -a opts=($_conan_common_options)
|
||||
local -a opts=($conan_common_options)
|
||||
case $words[1] in
|
||||
(add)
|
||||
opts+=(
|
||||
|
|
@ -499,10 +499,10 @@ _conan_lock() {
|
|||
'--requires[directly provide requires instead of a conanfile]:requires'
|
||||
'--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires'
|
||||
'--build-require[whether the provided reference is a build-require]'
|
||||
$_conan_remote_options[@]
|
||||
$conan_remote_options[@]
|
||||
$conan_profile_options[@]
|
||||
$conan_reference_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
'1: :_files'
|
||||
)
|
||||
;;
|
||||
|
|
@ -539,10 +539,10 @@ _conan_lock() {
|
|||
\*{-ubr,--update-build-requires}'[update build-requires from lockfile]:update_build_requires'
|
||||
\*{-upr,--update-python-requires}'[update python-requires from lockfile]:update_python_requires'
|
||||
'*--build-requires[update build-requires from lockfile]:build_requires'
|
||||
$_conan_remote_options[@]
|
||||
$conan_remote_options[@]
|
||||
$conan_profile_options[@]
|
||||
$conan_reference_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
)
|
||||
;;
|
||||
(upgrade-config)
|
||||
|
|
@ -550,10 +550,10 @@ _conan_lock() {
|
|||
'--requires[directly provide requires instead of a conanfile]:requires'
|
||||
'--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires'
|
||||
'*--update-config-requires[update config-requires from lockfile]:update_config_requires'
|
||||
$_conan_remote_options[@]
|
||||
$conan_remote_options[@]
|
||||
$conan_profile_options[@]
|
||||
$conan_reference_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
)
|
||||
;;
|
||||
esac
|
||||
|
|
@ -587,7 +587,7 @@ _conan_profile() {
|
|||
_describe -t 'commands' "command" commands && ret=0
|
||||
;;
|
||||
(args)
|
||||
local opts=($_conan_common_options[@])
|
||||
local opts=($conan_common_options[@])
|
||||
case $words[1] in
|
||||
(detect)
|
||||
opts+=(
|
||||
|
|
@ -625,7 +625,7 @@ _conan_remote() {
|
|||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'1:subcommand:->subcommand' \
|
||||
'*:: :->args' \
|
||||
&& ret=0
|
||||
|
|
@ -649,7 +649,7 @@ _conan_remote() {
|
|||
_describe -t 'commands' "command" commands && ret=0
|
||||
;;
|
||||
(args)
|
||||
local -a opts=($_conan_common_options[@])
|
||||
local -a opts=($conan_common_options[@])
|
||||
case $words[1] in
|
||||
(add)
|
||||
opts+=(
|
||||
|
|
@ -728,7 +728,7 @@ _conan_remote() {
|
|||
_conan_remove() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
'(-f --format)'{-f,--format}'[select the output format]:format:(json)'
|
||||
'(-c --confirm)'{-c,--confirm}'[remove without requesting a confirmation]'
|
||||
\*{-p,--package-query}'[remove only the packages matching a specific query]:query'
|
||||
|
|
@ -747,7 +747,7 @@ _conan_remove() {
|
|||
_conan_search() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
'(-f --format)'{-f,--format}'[select the output format]:format:(json)'
|
||||
\*{-r,--remote}'[will remove from the specified remote]:remote'
|
||||
'*:recipe_reference:_files'
|
||||
|
|
@ -761,7 +761,7 @@ _conan_search() {
|
|||
_conan_version() {
|
||||
local ret=1
|
||||
_arguments \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'(-f --format)'{-f,--format}'[select the output format]:format:(json)' \
|
||||
&& ret=0
|
||||
|
||||
|
|
@ -777,7 +777,7 @@ _conan_build() {
|
|||
local ret=1
|
||||
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
\*{-g,--generator}'[generators to use]:generator'
|
||||
'(-of --output-folder)'{-of,--output-folder}'[root output folder for generated and build files]:folder:_files -/'
|
||||
'(-d --deployer)'{-d,--deployer}'[deploy using the provided deployer to the output folder]:deployer:(full_deploy direct_deploy)'
|
||||
|
|
@ -786,9 +786,9 @@ _conan_build() {
|
|||
'--envs-generation[generation strategy for virtual environment files for the root]:flag:(false)'
|
||||
\*{-b,--build}'[optional, specify which packages to build from source]:build'
|
||||
$conan_reference_options[@]
|
||||
$_conan_remote_options[@]
|
||||
$conan_remote_options[@]
|
||||
$conan_profile_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
'*: :_files'
|
||||
)
|
||||
|
||||
|
|
@ -800,14 +800,14 @@ _conan_build() {
|
|||
_conan_create() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
\*{-b,--build}'[optional, specify which packages to build from source]:build'
|
||||
'(-u --update)'{-u,--update}'[will check the remote and in case a newer version]'
|
||||
'--build-require[whether the provided reference is a build-require]'
|
||||
'(-tf --test-folder)'{-tf,--test-folder}'[alternative test folder name]:folder:_files -/'
|
||||
$conan_reference_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$_conan_remote_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
$conan_remote_options[@]
|
||||
$conan_profile_options[@]
|
||||
'*: :_files -/'
|
||||
)
|
||||
|
|
@ -820,7 +820,7 @@ _conan_create() {
|
|||
_conan_download() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
'--only-recipe[download only the recipe, not the binary packages]'
|
||||
\*{-p,--package-query}'[only download packages matching a specific query]:query'
|
||||
'(-r --remote)'{-r,--remote}'[download from the specific remote]:remote:_conan_remotes'
|
||||
|
|
@ -839,7 +839,7 @@ _conan_editable() {
|
|||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'1:subcommand:->subcommand' \
|
||||
'*:: :->args' \
|
||||
&& ret=0
|
||||
|
|
@ -854,7 +854,7 @@ _conan_editable() {
|
|||
_describe -t 'commands' "command" commands && ret=0
|
||||
;;
|
||||
(args)
|
||||
local opts=($_conan_common_options[@])
|
||||
local opts=($conan_common_options[@])
|
||||
case $words[1] in
|
||||
(add)
|
||||
opts+=(
|
||||
|
|
@ -887,7 +887,7 @@ _conan_editable() {
|
|||
_conan_export() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
'(-f --format)'{-f,--format}'[select output format]:format:(json pkglist)'
|
||||
'(-r --remote -nr --no-remote)'{-r,--remote}'[remote names. Accepts wildcards("*")]:remote'
|
||||
'(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]'
|
||||
|
|
@ -907,7 +907,7 @@ _conan_export() {
|
|||
_conan_export-pkg() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
'(-of --output-folder)'{-of,--output-folder}'[root output folder for generated and build files]:folder:_files -/'
|
||||
'--build-require[whether the provided reference is a build-require]'
|
||||
'(-tf --test-folder)'{-tf,--test-folder}'[alternative test folder name]:folder:_files -/'
|
||||
|
|
@ -915,7 +915,7 @@ _conan_export-pkg() {
|
|||
'(-r --remote -nr --no-remote)'{-r,--remote}'[look in the specified remote or remote servers]:remote'
|
||||
'(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]'
|
||||
$conan_reference_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
$conan_profile_options[@]
|
||||
'*: :_files -/'
|
||||
)
|
||||
|
|
@ -930,7 +930,7 @@ _conan_require() {
|
|||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'1: :->subcommand' \
|
||||
'*:: :->args' \
|
||||
&& ret=1
|
||||
|
|
@ -953,7 +953,7 @@ _conan_require() {
|
|||
case $words[1] in
|
||||
(add)
|
||||
_arguments \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
$common_options[@] \
|
||||
'(-r --remote -nr --no-remote)'{-r,--remote}'[remote names. Accepts wildcards("*")]:remote' \
|
||||
'(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]' \
|
||||
|
|
@ -962,7 +962,7 @@ _conan_require() {
|
|||
;;
|
||||
(remove)
|
||||
_arguments \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
$common_options[@] \
|
||||
'*::name' \
|
||||
&& ret=0
|
||||
|
|
@ -983,7 +983,7 @@ _conan_new() {
|
|||
local_recipes_index workspace
|
||||
)
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
\*{-d,--define}'[define a template argument as key=value]:key_value'
|
||||
'(-f --force)'{-f,--force}'[overwrite file if it already exists]'
|
||||
'(-o --output)'{-o,--output}'[output folder for the generated files]:folder:_files -/'
|
||||
|
|
@ -998,7 +998,7 @@ _conan_new() {
|
|||
_conan_source() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
$conan_reference_options[@]
|
||||
'1: :_files'
|
||||
)
|
||||
|
|
@ -1011,11 +1011,11 @@ _conan_source() {
|
|||
_conan_test() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
\*{-b,--build}'[optional, specify which packages to build from source]:build'
|
||||
$_conan_remote_options[@]
|
||||
$conan_remote_options[@]
|
||||
$conan_profile_options[@]
|
||||
$_conan_lockfile_options[@]
|
||||
$conan_lockfile_options[@]
|
||||
'1:path:_files -/'
|
||||
'2:reference'
|
||||
)
|
||||
|
|
@ -1028,7 +1028,7 @@ _conan_test() {
|
|||
_conan_upload() {
|
||||
local ret=1
|
||||
local -a opts=(
|
||||
$_conan_common_options[@]
|
||||
$conan_common_options[@]
|
||||
\*{-p,--package-query}'[only upload packages matching a specific query]:query'
|
||||
'(-r --remote)'{-r,--remote}'[upload to this specific remote]:remote:_conan_remotes'
|
||||
'--only-recipe[upload only the recipe, not the binary packages]'
|
||||
|
|
@ -1056,7 +1056,7 @@ _conan_audit() {
|
|||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'1: :->subcommand' \
|
||||
'*:: :->args' \
|
||||
&& ret=1
|
||||
|
|
@ -1074,7 +1074,7 @@ _conan_audit() {
|
|||
case $words[1] in
|
||||
(list)
|
||||
_arguments \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'(-f --format)'{-f,--format}'[select the output format]:format:(json html)' \
|
||||
'(-l --list)'{-l,--list}'[package list file to list vulnerabilities for]:list:_files' \
|
||||
'(-s --sbom)'{-s,--sbom}'[SBOM file to list vulnerabilities for]:sbom:_files' \
|
||||
|
|
@ -1086,7 +1086,7 @@ _conan_audit() {
|
|||
;;
|
||||
(provider)
|
||||
_arguments \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'(-f --format)'{-f,--format}'[select the output format]:format:(json html)' \
|
||||
'--url[provider URL]:url' \
|
||||
'--type[provider type]:type:(conan-center-proxy private)' \
|
||||
|
|
@ -1097,17 +1097,17 @@ _conan_audit() {
|
|||
;;
|
||||
(scan)
|
||||
_arguments \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
\*{-b,--build}'[specify which packages to build from source]:build:(never missing cascade)' \
|
||||
'--requires[directly provide requires instead of a conanfile]:requires' \
|
||||
'--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires' \
|
||||
'(-sl --severity-level)'{-sl,--severity-level}'[set threshold for severity level to raise an error]:level' \
|
||||
'--context[context to scan]:context:(host build)' \
|
||||
'(-p --provider)'{-p,--provider}'[provider to use for scanning]' \
|
||||
$_conan_remote_options[@] \
|
||||
$conan_remote_options[@] \
|
||||
$conan_profile_options[@] \
|
||||
$conan_reference_options[@] \
|
||||
$_conan_lockfile_options[@] \
|
||||
$conan_lockfile_options[@] \
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1123,7 +1123,7 @@ _conan_report() {
|
|||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'1: :->subcommand' \
|
||||
'*:: :->args' \
|
||||
&& ret=1
|
||||
|
|
@ -1139,7 +1139,7 @@ _conan_report() {
|
|||
case $words[1] in
|
||||
(diff)
|
||||
_arguments \
|
||||
$_conan_common_options[@] \
|
||||
$conan_common_options[@] \
|
||||
'(-op --old-path)'{-op,--old-path}'[path to the old recipe]:path:_files' \
|
||||
'(-or --old-reference)'{-or,--old-reference}'[old reference]:reference' \
|
||||
'(-np --new-path)'{-np,--new-path}'[path to the new recipe]:path:_files' \
|
||||
|
|
|
|||
Loading…
Reference in New Issue