]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/cabal/cabal.plugin.zsh
a9a05b01245e67dd554d0ff1af87092a7f4967bc
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / cabal / cabal.plugin.zsh
1 function cabal_sandbox_info() {
2     cabal_files=(*.cabal(N))
3     if [ $#cabal_files -gt 0 ]; then
4         if [ -f cabal.sandbox.config ]; then
5             echo "%{$fg[green]%}sandboxed%{$reset_color%}"
6         else
7             echo "%{$fg[red]%}not sandboxed%{$reset_color%}"
8         fi
9     fi
10 }
11
12 function _cabal_commands() {
13     local ret=1 state
14     _arguments ':subcommand:->subcommand' && ret=0
15
16     case $state in
17       subcommand)
18         subcommands=(
19           "bench:Run the benchmark, if any (configure with UserHooks)"
20           "build:Compile all targets or specific target."
21           "check:Check the package for common mistakes"
22           "clean:Clean up after a build"
23           "copy:Copy the files into the install locations"
24           "configure:Prepare to build the package"
25           "exec:Run a command with the cabal environment"
26           "fetch:Downloads packages for later installation"
27           "freeze:Freeze dependencies."
28           "get:Gets a package's source code"
29           "haddock:Generate Haddock HTML documentation"
30           "help:Help about commands"
31           "hscolour:Generate HsColour colourised code, in HTML format"
32           "info:Display detailed information about a particular package"
33           "init:Interactively create a .cabal file"
34           "install:Installs a list of packages"
35           "list:List packages matching a search string"
36           "register:Register this package with the compiler"
37           "repl:Open an interpreter session for the given target"
38           "report:Upload build reports to a remote server"
39           "run:Runs the compiled executable"
40           "sandbox:Create/modify/delete a sandbox"
41           "sdist:Generate a source distribution file (.tar.gz)"
42           "test:Run the test suite, if any (configure with UserHooks)"
43           "unpack:Unpacks packages for user inspection"
44           "update:Updates list of known packages"
45           "upload:Uploads source packages to Hackage"
46         )
47         _describe -t subcommands 'cabal subcommands' subcommands && ret=0
48     esac
49
50     return ret
51 }
52
53 compdef _cabal_commands cabal
54
55 function _cab_commands() {
56     local ret=1 state
57     _arguments ':subcommand:->subcommand' && ret=0
58
59     case $state in
60       subcommand)
61         subcommands=(
62           "sync:Fetch the latest package index"
63           "install:Install packages"
64           "uninstall:Uninstall packages"
65           "installed:List installed packages"
66           "configure:Configure a cabal package"
67           "build:Build a cabal package"
68           "clean:Clean up a build directory"
69           "outdated:Display outdated packages"
70           "info:Display information of a package"
71           "sdist:Make tar.gz for source distribution"
72           "upload:Uploading tar.gz to HackageDB"
73           "get:Untar a package in the current directory"
74           "deps:Show dependencies of this package"
75           "revdeps:Show reverse dependencies of this package"
76           "check:Check consistency of packages"
77           "genpaths:Generate Paths_<pkg>.hs"
78           "search:Search available packages by package name"
79           "add:Add a source directory"
80           "test:Run tests"
81           "bench:Run benchmarks"
82           "doc:Generate manuals"
83           "ghci:Run GHCi (with a sandbox)"
84           "init:Initialize a sandbox"
85           "help:Display the help message of the command"
86         )
87         _describe -t subcommands 'cab subcommands' subcommands && ret=0
88     esac
89
90     return ret
91 }
92
93 command -v cab >/dev/null 2>&1 && { compdef _cab_commands cab }