cabal.plugin.zsh 3.5 KB

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