2
0

_lein 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #compdef lein
  2. # Lein ZSH completion function
  3. # Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions)
  4. # and rename it _lein
  5. _lein() {
  6. if (( CURRENT > 2 )); then
  7. # shift words so _arguments doesn't have to be concerned with second command
  8. (( CURRENT-- ))
  9. shift words
  10. # use _call_function here in case it doesn't exist
  11. _call_function 1 _lein_${words[1]}
  12. else
  13. _values "lein command" \
  14. "change[Rewrite project.clj by applying a function.]" \
  15. "check[Check syntax and warn on reflection.]" \
  16. "classpath[Print the classpath of the current project.]" \
  17. "clean[Remove all files from project's target-path.]" \
  18. "compile[Compile Clojure source into .class files.]" \
  19. "deploy[Build and deploy jar to remote repository.]" \
  20. "deps[Download all dependencies.]" \
  21. "do[Higher-order task to perform other tasks in succession.]" \
  22. "help[Display a list of tasks or help for a given task.]" \
  23. "install[Install the current project to the local repository.]" \
  24. "jar[Package up all the project's files into a jar file.]" \
  25. "javac[Compile Java source files.]" \
  26. "new[Generate project scaffolding based on a template.]" \
  27. "plugin[DEPRECATED. Please use the :user profile instead.]" \
  28. "pom[Write a pom.xml file to disk for Maven interoperability.]" \
  29. "release[Perform :release-tasks.]" \
  30. "repl[Start a repl session either with the current project or standalone.]" \
  31. "retest[Run only the test namespaces which failed last time around.]" \
  32. "run[Run a -main function with optional command-line arguments.]" \
  33. "search[Search remote maven repositories for matching jars.]" \
  34. "show-profiles[List all available profiles or display one if given an argument.]" \
  35. "test[Run the project's tests.]" \
  36. "trampoline[Run a task without nesting the project's JVM inside Leiningen's.]" \
  37. "uberjar[Package up the project files and dependencies into a jar file.]" \
  38. "update-in[Perform arbitrary transformations on your project map.]" \
  39. "upgrade[Upgrade Leiningen to specified version or latest stable.]" \
  40. "vcs[Interact with the version control system.]" \
  41. "version[Print version for Leiningen and the current JVM.]" \
  42. "with-profile[Apply the given task with the profile(s) specified.]"
  43. fi
  44. }
  45. _lein_plugin() {
  46. _values "lein plugin commands" \
  47. "install[Download, package, and install plugin jarfile into ~/.lein/plugins]" \
  48. "uninstall[Delete the plugin jarfile: \[GROUP/\]ARTIFACT-ID VERSION]"
  49. }
  50. _lein_namespaces() {
  51. if [ -f "./project.clj" -a -d "$1" ]; then
  52. _values "lein valid namespaces" \
  53. $(find "$1" -type f -name "*.clj" -exec awk '/^\(ns */ {gsub("\\)", "", $2); print $2}' '{}' '+')
  54. fi
  55. }
  56. _lein_run() {
  57. _lein_namespaces "src/"
  58. }
  59. _lein_test() {
  60. _lein_namespaces "test/"
  61. }