#compdef conan
# ------------------------------------------------------------------------------
# Copyright (c) 2010-2017 Github zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the zsh-users nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
#  Completion script for conan 0.28.1 (https://www.conan.io).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
#  * Julien Nicoulaud <julien.nicoulaud@gmail.com>
#
# ------------------------------------------------------------------------------


_conan() {

  local context state state_descr line
  typeset -A opt_args

  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(- : *)'{-v,--version}'[display version information]' \
    '(-h --help)1: :_conan_commands' \
    '(-h --help)*:: :->command_args'

  case $state in
    command_args)
      (( $+functions[_conan_${words[1]}_args] )) && _conan_${words[1]}_args
    ;;
  esac
}

(( $+functions[_conan_commands] )) ||
_conan_commands() {
  local consumer_commands creator_commands package_development_commands misc_commands deprecated_commands
  consumer_commands=(
	  'install:installs the requirements specified in a "conanfile.py" or "conanfile.txt"'
	  'config:manages conan configuration information'
 	  'get:gets a file or list a directory of a given reference or package'
	  'info:prints information about a package recipe'\''s dependency graph'
	  'search:search package recipes and binaries in the local cache or in a remote server'
  )
  creator_commands=(
	  'new:creates a new package recipe template with a '\''conanfile.py'\'''
 	  'create:export, build package and test it with a consumer project'
	  'upload:uploads a package recipe and the generated binary packages to a specified remote'
	  'export:copies the package recipe (conanfile.py and associated files) to your local cache'
	  'export-pkg:exports a recipe & creates a package with given files calling '\''package'\'''
	  'test:runs a test-folder/conanfile.py to test an existing package'
  )
  package_development_commands=(
	  'source:calls your conanfile.py "source()" method to configure the source directory'
	  'build:utility command to run your current project "conanfile.py" build() method'
	  'package:calls your conanfile.py "package" method for a specific package recipe'
  )
  misc_commands=(
	  'profile:list profiles in the ".conan/profiles" folder, or show profile details'
	  'remote:handles the remote list and the package recipes associated to a remote'
	  'user:update your cached user name (and auth token) to avoid it being requested later'
	  'imports:execute the "imports" stage of a conanfile.txt or a conanfile.py'
	  'copy:copy conan recipes and packages to another user/channel.'
	  'remove:remove any package recipe or binary matching a pattern'
	  'alias:creates and export an alias recipe'
  )
  _describe -t 'consumer-commands' "consumer commands" consumer_commands
  _describe -t 'creator-commands' "creator commands" creator_commands
  _describe -t 'package-development-commands' "package development commands" package_development_commands
  _describe -t 'misc-commands' "misc commands" misc_commands
}

(( $+functions[_conan_alias_args] )) ||
_conan_alias_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1:alias reference:_conan_package_references' \
    '(-h --help)2:target reference:_conan_package_references'
}

(( $+functions[_conan_build_args] )) ||
_conan_build_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    "(-h --help -f --file)"{-f,--file}'[specify conanfile filename]: :_conan_conanfiles' \
    "(-h --help -sf --source-folder)"{-sf,--source-folder}'[local folder containing the sources. Defaulted to the directory of the conanfile. A relative path can also be specified (relative to the current directory)]: :_files -/' \
    "(-h --help -bf --build-folder)"{-bf,--build-folder}'[build folder, working directory of the build process. Defaulted to the current directory. A relative path can also be specified (relative to the current directory)]: :_files -/' \
    "(-h --help -pf --package-folder)"{-pf,--package-folder}'[folder to install the package (when the build system or build() method does it). Defaulted to the '\''{build_folder}/package'\'' folder. A relative path can be specified, relative to the current folder. Also an absolute path is allowed.]: :_files -/' \
    "(-h --help -if --install-folder)"{-if,--install-folder}'[local folder containing the conaninfo.txt and conanbuildinfo.txt files (from a previous conan install execution). Defaulted to --build-folder]: :_files -/' \
    '(-h --help)1: :_conan_conanfiles'
}

(( $+functions[_conan_config_args] )) ||
_conan_config_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_config_commands' \
    '(-h --help)*:: :->command_args'

  case $state in
    command_args)
      (( $+functions[_conan_config_${words[1]}_args] )) && _conan_config_${words[1]}_args
    ;;
  esac
}

(( $+functions[_conan_config_commands] )) ||
_conan_config_commands() {
  local commands
  commands=(
	  'rm:rm an existing config element'
	  'set:set/add value'
	  'get:get the value of existing element'
	  'install:install a full configuration from a zip file, local or remote'
  )
  _describe -t 'commands' "command" commands
}

(( $+functions[_conan_config_rm_args] )) ||
_conan_config_rm_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_config_keys'
}

(( $+functions[_conan_config_get_args] )) ||
_conan_config_get_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_config_keys'
}

(( $+functions[_conan_config_set_args] )) ||
_conan_config_set_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_config_set_key_values'
}

(( $+functions[_conan_config_set_key_values] )) ||
_conan_config_set_key_values() {
  local ret=1
  if compset -P '*='; then
    _wanted property-values expl 'config value' _conan_config_values ${IPREFIX%=} && ret=0
  else
    _wanted property-names expl 'config key' _conan_config_keys -qS= && ret=0
  fi
  return ret
}

(( $+functions[_conan_config_install_args] )) ||
_conan_config_install_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1:config file:_files'
}

(( $+functions[_conan_copy_args] )) ||
_conan_copy_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    "(-h --help --all -p --package)"{-p,--package}'[copy specified package ID]:package reference:_conan_package_references' \
    '(-h --help --all -p --package)--all[copy all packages from the specified package recipe]' \
    '(-h --help --force)--force[override destination packages and the package recipe]' \
    '(-h --help)1: :_conan_package_references' \
    '(-h --help)2: :_conan_user_channels'
}

(( $+functions[_conan_export_args] )) ||
_conan_export_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help -p --path)'{-p,--path}'[folder with a conanfile.py (default current directory)]: :_files -/' \
    '(-h --help -k --keep-source)'{-k,--keep-source}'[do not remove the source folder in the local cache]' \
    '(-h --help -f --file)'{-f,--file}'[specify conanfile filename]: :_conan_conanfiles' \
    '(-h --help)1: :_conan_channel_or_package_references'
}

(( $+functions[_conan_get_args] )) ||
_conan_get_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    "(-h --help -p --package)"{-p,--package}'[package ID]: :_conan_package_references' \
    '(-h --help -r --remote)'{-r,--remote}'[get from this specific remote]: :_conan_remotes' \
    '(-h --help -raw --raw)'{-raw,--raw}'[do not decorate the text]' \
    '(-h --help)1: :_conan_package_references' \
    '(-h --help)2:file or directory path:_files'
}

(( $+functions[_conan_imports_args] )) ||
_conan_imports_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help -f --file)'{-f,--file}'[use another filename]: :_conan_conanfiles' \
    '(-h --help -imf --import-folder)'{-imf,--import-folder}'[directory to copy the artifacts to. By default it will be the current directory]: :_files -/' \
    '(-h --help -if --install-folder)'{-if,--install-folder}'[local folder containing the conaninfo.txt and conanbuildinfo.txt files (from a previous conan install execution)]: :_files -/' \
    '(-h --help -u --undo)'{-u,--undo}'[undo imports (remove imported files)]' \
    '(-h --help)1: :_conan_directory_or_package_references'
}

(( $+functions[_conan_info_args] )) ||
_conan_info_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help -f --file)'{-f,--file}'[specify conanfile filename]: :_conan_conanfiles' \
    '(-h --help -n --only)'{-n,--only}'[filter fields]: :_conan_info_only_values' \
    '(-h --help --paths)--paths[show package paths in local cache]' \
    '(-h --help --package-filter)--package-filter[print information only for packages that match the filtere.g., MyPackage/1.2@user/channel or MyPackage*]: :_conan_package_references' \
    '(-h --help -bo --build_order)'{-bo,--build_order}'[given a modified reference, return an ordered list to build (CI)]' \
    '(-h --help -j --json)'{-j,--json}'[only with --build_order option, return the information in a json]: :_files -g "*.json"' \
    '(-h --help -g --graph)'{-g,--graph}'[creates file with project dependencies graph]: :_files -g "*.(dot|html)"' \
    '(-h --help -u --update)'{-u,--update}'[check updates exist from upstream remotes]' \
    '(-h --help -sc --scope)'{-sc,--scope}'[use the specified scope in the install command]: :_conan_scopes' \
    '(-h --help -pr --profile)'{-pr,--profile}'[apply the specified profile to the install command]: :_conan_profiles' \
    '(-h --help -r --remote)'{-r,--remote}'[look in the specified remote server]: :_conan_remotes' \
    '(-h --help)'{-o,--options}'[options to build the package, overwriting the defaults. e.g., -o with_qt=true]: :_conan_options' \
    '(-h --help)'{-s,--settings}'[settings to build the package, overwriting the defaults. e.g., -s compiler=gcc]: :_conan_settings' \
    '(-h --help)'{-e,--env}'[environment variables that will be set during the package build, -e CXX=/usr/bin/clang++]: :_conan_environment_variables' \
    '(-h --help -b --build)'{-b,--build}'[given a build policy (same install command "build" parameter), return an ordered list of packages that would be built from sources in install command (simulation)]: :_conan_build_policies' \
    '(-h --help)1: :_conan_conanfiles_or_package_references'
}

(( $+functions[_conan_info_only_values] )) ||
_conan_info_only_values() {
  local values
  values=(
	  'id:show only "id"'
	  'build_id:show only "build_id"'
	  'remote:show only "remote"'
	  'url:show only "url"'
	  'license:show only "license"'
	  'requires:show only "requires"'
	  'update:show only "update"'
	  'required:show only "required"'
	  'date:show only "date"'
	  'author:show only "author"'
	  'export_folder:use with --paths'
	  'build_folder:use with --paths'
	  'package_folder:use with --paths'
	  'source_folder:use with --paths'
	  'None:show only references'
  )
  _describe -t 'values' "value" values
}

(( $+functions[_conan_install_args] )) ||
_conan_install_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help -f --file)'{-f,--file}'[specify conanfile filename]: :_conan_conanfiles' \
    '(-h --help -g --generator)'{-g,--generator}'[generators to use]: :_conan_generators' \
    '(-h --help --werror)--werror[error instead of warnings for graph inconsistencies]' \
    '(-h --help -if --install-folder)'{-if,--install-folder}'[Use this directory as the directory where to put the generatorfiles, conaninfo/conanbuildinfo.txt etc.]: :_files -/' \
    '(-h --help -m --manifests)'{-m,--manifests}'[install dependencies manifests in folder for later verify]: :_files -/' \
    '(-h --help -mi --manifests-interactive)'{-mi,--manifests-interactive}'[install dependencies manifests in folder for later verify]: :_files -/' \
    '(-h --help -v --verify)'{-v,--verify}'[verify dependencies manifests against stored ones]: :_files -/' \
    '(-h --help --no-imports)--no-imports[install specified packages but avoid running imports]' \
    '(-h --help -u --update)'{-u,--update}'[check updates exist from upstream remotes]' \
    '(-h --help -sc --scope)'{-sc,--scope}'[use the specified scope in the install command]: :_conan_scopes' \
    '(-h --help -pr --profile)'{-pr,--profile}'[apply the specified profile to the install command]: :_conan_profiles' \
    '(-h --help -r --remote)'{-r,--remote}'[look in the specified remote server]: :_conan_remotes' \
    '(-h --help)'{-o,--options}'[options to build the package, overwriting the defaults. e.g., -o with_qt=true]: :_conan_options' \
    '(-h --help)'{-s,--settings}'[settings to build the package, overwriting the defaults. e.g., -s compiler=gcc]: :_conan_settings' \
    '(-h --help)'{-e,--env}'[environment variables that will be set during the package build, -e CXX=/usr/bin/clang++]: :_conan_environment_variables' \
    '(-h --help -b --build)'{-b,--build}'[given a build policy (same install command "build" parameter), return an ordered list of packages that would be built from sources in install command (simulation)]: :_conan_build_policies' \
    '(-h --help)1: :_conan_conanfiles'
}

(( $+functions[_conan_new_args] )) ||
_conan_new_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help -t --test)'{-t,--test}'[create test_package skeleton to test package]' \
    '(-h --help -i --header)'{-i,--header}'[create a headers only package template]' \
    '(-h --help -c --pure_c)'{-c,--pure_c}'[create a C language package only package, deleting "self.settings.compiler.libcxx" setting in the configure method]' \
    '(-h --help -s --sources)'{-s,--sources}'[create a package with embedded sources in "src" folder, using "exports_sources" instead of retrieving external code with the "source()" method]' \
    '(-h --help -b --bare)'{-b,--bare}'[create the minimum package recipe, without build() or package() methods. Useful in combination with "package_files" command]' \
    '(-h --help -cis --ci_shared)'{-cis,--ci_shared}'[package will have a "shared" option to be used in CI]' \
    '(-h --help -cilg --ci_travis_gcc)'{-cilg,--ci_travis_gcc}'[generate travis-ci files for linux gcc]' \
    '(-h --help -cilc --ci_travis_clang)'{-cilc,--ci_travis_clang}'[generate travis-ci files for linux clang]' \
    '(-h --help -cilg --ci_travis_gcc)'{-cilg,--ci_travis_gcc}'[generate travis-ci files for linux gcc]' \
    '(-h --help -cio --ci_travis_osx)'{-cio,--ci_travis_osx}'[generate travis-ci files for OSX apple-clang]' \
    '(-h --help -ciw --ci_appveyor_win)'{-ciw,--ci_appveyor_win}'[generate appveyor files for Appveyor Visual Studio]' \
    '(-h --help -ciglg --ci_gitlab_gcc)'{-ciglg,--ci_gitlab_gcc}'[generate GitLab files for linux gcc]' \
    '(-h --help -ciglc --ci_gitlab_clang)'{-ciglc,--ci_gitlab_clang}'[generate GitLab files for linux clang]' \
    '(-h --help -cilg --ci_travis_gcc)'{-cilg,--ci_travis_gcc}'[generate travis-ci files for linux gcc]' \
    '(-h --help -gi --gitignore)'{-gi,--gitignore}'[generate a .gitignore with the known patterns to excluded]' \
    '(-h --help -ciu --ci_upload_url)'{-ciu,--ci_upload_url}'[define URL of the repository to upload]: :_urls' \
    '(-h --help)1: :_conan_package_references'
}

(( $+functions[_conan_package_args] )) ||
_conan_package_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    "(-h --help -sf --source-folder)"{-sf,--source-folder}'[local folder containing the sources. Defaulted to the directory of the conanfile. A relative path can also be specified (relative to the current directory)]: :_files -/' \
    "(-h --help -bf --build-folder)"{-bf,--build-folder}'[build folder, working directory of the build process. Defaulted to the current directory. A relative path can also be specified (relative to the current directory)]: :_files -/' \
    "(-h --help -pf --package-folder)"{-pf,--package-folder}'[folder to install the package (when the build system or build() method does it). Defaulted to the '\''{build_folder}/package'\'' folder. A relative path can be specified, relative to the current folder. Also an absolute path is allowed.]: :_files -/' \
    "(-h --help -if --install-folder)"{-if,--install-folder}'[local folder containing the conaninfo.txt and conanbuildinfo.txt files (from a previous conan install execution). Defaulted to --build-folder]: :_files -/' \
    '(-h --help)1: :_conan_package_references' \
    '(-h --help)2:package ID:'
}

(( $+functions[_conan_profile_args] )) ||
_conan_profile_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_profile_commands' \
    '(-h --help)*:: :->command_args'

  case $state in
    command_args)
      (( $+functions[_conan_profile_${words[1]}_args] )) && _conan_profile_${words[1]}_args
    ;;
  esac
}

(( $+functions[_conan_profile_commands] )) ||
_conan_profile_commands() {
  local commands
  commands=(
    'list:list current profiles'
    'show:show the values defined for a profile'
    'new:creates a new empty profile'
    'update:update a profile'
    'get:get a profile key'
    'remove:remove a profile key'
  )
  _describe -t 'commands' "command" commands
}

(( $+functions[_conan_profile_list_args] )) ||
_conan_profile_list_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]'
}

(( $+functions[_conan_profile_show_args] )) ||
_conan_profile_show_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_profiles'
}

(( $+functions[_conan_profile_new_args] )) ||
_conan_profile_new_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)--detect[autodetect settings and fill \[settings\] section]' \
    '(-h --help)1:profile name:'
}

(( $+functions[_conan_profile_update_args] )) ||
_conan_profile_update_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_settings' \
    '(-h --help)2: :_conan_profiles'
}

(( $+functions[_conan_profile_get_args] )) ||
_conan_profile_get_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_setting_keys' \
    '(-h --help)2: :_conan_profiles'
}

(( $+functions[_conan_profile_remove_args] )) ||
_conan_profile_remove_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_setting_keys' \
    '(-h --help)2: :_conan_profiles'
}

(( $+functions[_conan_remote_args] )) ||
_conan_remote_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_remote_commands' \
    '(-h --help)*:: :->command_args'

  case $state in
    command_args)
      (( $+functions[_conan_remote_${words[1]}_args] )) && _conan_remote_${words[1]}_args
    ;;
  esac
}

(( $+functions[_conan_remote_commands] )) ||
_conan_remote_commands() {
  local commands
  commands=(
    'list:list current remotes'
    'add:add a remote'
    'remove:remove a remote'
    'update:update the remote url'
    'list_ref:list the package recipes and its associated remotes'
    'add_ref:associate a recipe'\''s reference to a remote'
    'remove_ref:dissociate a recipe'\''s reference and its remote'
    'update_ref:update the remote associated with a package recipe'
  )
  _describe -t 'commands' "command" commands
}

(( $+functions[_conan_remote_list_args] )) ||
_conan_remote_list_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]'
}

(( $+functions[_conan_remote_add_args] )) ||
_conan_remote_add_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1:name of the remote:' \
    '(-h --help)2:url of the remote:_urls' \
    '(-h --help)3:verify SSL certificated:(True False)'
}

(( $+functions[_conan_remote_remove_args] )) ||
_conan_remote_remove_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_remotes'
}

(( $+functions[_conan_remote_update_args] )) ||
_conan_remote_update_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(-h --help)1: :_conan_remotes' \
    '(-h --help)2:url of the remote:_urls' \
    '(-h --help)3:verify SSL certificated:(True False)'
}

(( $+functions[_conan_remote_list_ref_args] )) ||
_conan_remote_list_ref_args() {
  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]'
}

# TODO complete conan remote add_ref
# TODO complete conan remote remove_ref
# TODO complete conan remote update_ref
# TODO complete conan remove
# TODO complete conan search
# TODO complete conan source
# TODO complete conan upload
# TODO complete conan user
# TODO complete conan export-pkg
# TODO complete conan test


(( $+functions[_conan_conanfiles] )) ||
_conan_conanfiles() {
  _files -g '*.py'
}

(( $+functions[_conan_conanfiles_or_package_references] )) ||
_conan_conanfiles_or_package_references() {
  _alternative \
    'conanfile: :_conan_conanfiles' \
    'package-references: :_conan_package_references'
}

(( $+functions[_conan_directory_or_package_references] )) ||
_conan_directory_or_package_references() {
  _alternative \
    'directory: :_files -/' \
    'package-references: :_conan_package_references'
}

(( $+functions[_conan_channel_or_package_references] )) ||
_conan_channel_or_package_references() {
  _alternative \
    'package-references: :_conan_package_references' \
    'user-channels: :_conan_user_channels'
}

(( $+functions[_conan_package_references] )) ||
_conan_package_references() {
  _guard '[^\-]#' 'package reference'  # TODO complete package references
}

(( $+functions[_conan_user_channels] )) ||
_conan_user_channels() {
  _guard '[^\-]#' 'user channel' # TODO complete user channels
}

(( $+functions[_conan_remotes] )) ||
_conan_remotes() {
  local remotes; remotes=(${(f)"$(_call_program remotes $service remote list)"})
  _describe -t remotes 'remote' remotes "$@"
}

(( $+functions[_conan_scopes] )) ||
_conan_scopes() {
  _guard '[^\-]#' 'scope' # TODO complete scopes
}

(( $+functions[_conan_build_policies] )) ||
_conan_build_policies() {
  _guard '[^\-]#' 'build policy' # TODO complete build policies
}

(( $+functions[_conan_generators] )) ||
_conan_generators() {
  _guard '[^\-]#' 'generator' # TODO complete generators
}

(( $+functions[_conan_profiles] )) ||
_conan_profiles() {
  local profiles; profiles=(${(f)"$(_call_program profiles $service profile list)"})
  _describe -t profiles 'profile' profiles "$@"
}

(( $+functions[_conan_config_keys] )) ||
_conan_config_keys() {
  _guard '[^\-]#' 'config key' # TODO complete config keys
}

(( $+functions[_conan_config_values] )) ||
_conan_config_values() {
  _guard '[^\-]#' 'config value' # TODO complete config values
}

(( $+functions[_conan_options] )) ||
_conan_options() {
  local ret=1
  if compset -P '*='; then
    _wanted option-values expl 'option value' _conan_option_values ${IPREFIX%=} && ret=0
  else
    _wanted option-names expl 'option key' _conan_option_keys -qS= && ret=0
  fi
  return ret
}

(( $+functions[_conan_option_keys] )) ||
_conan_option_keys() {
  _guard '[^\-]#' 'option key' # TODO complete option keys
}

(( $+functions[_conan_option_values] )) ||
_conan_option_values() {
  _guard '[^\-]#' 'option value' # TODO complete option values
}

(( $+functions[_conan_settings] )) ||
_conan_settings() {
  local ret=1
  if compset -P '*='; then
    _wanted setting-values expl 'setting value' _conan_setting_values ${IPREFIX%=} && ret=0
  else
    _wanted setting-names expl 'setting key' _conan_setting_keys -qS= && ret=0
  fi
  return ret
}

(( $+functions[_conan_setting_keys] )) ||
_conan_setting_keys() {
  _guard '[^\-]#' 'setting key' # TODO complete setting keys
}

(( $+functions[_conan_setting_values] )) ||
_conan_setting_values() {
  _guard '[^\-]#' 'setting value' # TODO complete setting values
}

(( $+functions[_conan_environment_variables] )) ||
_conan_environment_variables() {
  local ret=1
  if compset -P '*='; then
    _wanted environment_variable-values expl 'environment variable value' _conan_environment_variable_values ${IPREFIX%=} && ret=0
  else
    _wanted environment_variable-names expl 'environment variable' _conan_environment_variable_keys -qS= && ret=0
  fi
  return ret
}

(( $+functions[_conan_environment_variable_keys] )) ||
_conan_environment_variable_keys() {
  _parameters -g "*export*"
}

(( $+functions[_conan_environment_variable_values] )) ||
_conan_environment_variable_values() {
  _guard '[^\-]#' 'environment variable value' # TODO complete environment variable values
}


_conan "$@"

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et
