#compdef stack
# ------------------------------------------------------------------------------
# Copyright (c) 2015 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 stack (https://github.com/commercialhaskell/stack).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
#  * Toshiki Teramura <toshiki.teramura@gmail.com>
#
# ------------------------------------------------------------------------------

_stack () {
    _arguments \
        --version'[Show version]' \
        --help'[Show this help text]' \
        '--docker*''[Run "stack --docker-help" for details]' \
        --verbosity'[Verbosity: silent, error, warn, info, debug]' \
        {-v,--verbose}'[Enable verbose mode: verbosity level "debug"]' \
        --system-ghc'[Enable using the system installed GHC (on the PATH) if available and a matching version]' \
        --no-system-ghc'[Disable using the system installed GHC (on the PATH) if available and a matching version]' \
        --install-ghc'[Enable downloading and installing GHC if necessary (can be done manually with stack setup)]' \
        --no-install-ghc'[Disable downloading and installing GHC if necessary (can be done manually with stack setup)]' \
        --arch'[System architecture, e.g. i386, x86_64]' \
        --os'[Operating system, e.g. linux, windows]' \
        {-j,--jobs}'[Number of concurrent jobs to run]' \
        --extra-include-dirs'[Extra directories to check for C header files]' \
        --extra-lib-dirs'[Extra directories to check for libraries]' \
        --skip-ghc-check'[Enable skipping the GHC version and architecture check]' \
        --no-skip-ghc-check'[Disable skipping the GHC version and architecture check]' \
        --skip-msys'[Enable skipping the local MSYS installation (Windows only)]' \
        --no-skip-msys'[Disable skipping the local MSYS installation (Windows only)]' \
        --resolver'[Override resolver in project file]' \
        --no-terminal'[Override terminal detection in the case of running in a false terminal]' \
        --stack-yaml'[Override project stack.yaml file (overrides any STACK_YAML environment variable)]' \
        '*: :__stack_modes'
}

__stack_modes () {
    _values \
        'subcommand' \
        'build[Build the project(s) in this directory/configuration]' \
        'install[Build executables and install to a user path]' \
        'test[Build and test the project(s) in this directory/configuration]' \
        'bench[Build and benchmark the project(s) in this directory/configuration]' \
        'haddock[Generate haddocks for the project(s) in this directory/configuration]' \
        'new[Create a brand new project]' \
        'init[Initialize a stack project based on one or more cabal packages]' \
        'solver[Use a dependency solver to try and determine missing extra-deps]' \
        'setup[Get the appropriate ghc for your project]' \
        'path[Print out handy path information]' \
        'unpack[Unpack one or more packages locally]' \
        'update[Update the package index]' \
        'upgrade[Upgrade to the latest stack (experimental)]' \
        'upload[Upload a package to Hackage]' \
        'dot[Visualize your projects dependency graph using Graphviz dot]' \
        'exec[Execute a command]' \
        'ghc[Run ghc]' \
        'ghci[Run ghci in the context of project(s)]' \
        'ide[Run ide-backend-client with the correct arguments]' \
        'runghc[Run runghc]' \
        'clean[Clean the local packages]' \
        'docker[Subcommands specific to Docker use]'

}
