cabal.plugin.zsh 3.2 KB

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