Guest User

Untitled

a guest
May 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. #compdef clbuild
  2.  
  3. # TODO: clbuild-bash-completion.sh stuff (run/update/install/uninstall)
  4. # Especially `update' found in this script is totally broken:)
  5.  
  6. _clbuild () {
  7. local clbuild_dir=${clbuild_dir:=$(pwd)}
  8.  
  9. (( $+functions[__clbuild_commands] )) ||
  10. __clbuild_commands () {
  11. local -a commands
  12. commands=(
  13. 'check:check availability of all necessary helper applications'
  14. 'list:[PATTERN] list all projects, or projects matching PATTERN'
  15. # update [--dependencies|--no-dependencies] PROJECT_SPEC
  16. # download/update this project
  17. # update [--resume]
  18. # download/update main projects. With --resume, consider
  19. # only projects that a previous update run failed to fetch.
  20. 'update:[--dependencies|--no-dependencies] PROJECT_SPEC/[--resume]'
  21. 'skip:PROJECT_NAME mark this project as done for the purposes of update --resume'
  22. 'recompile:PROJECT_SPEC compile fasls'
  23. 'dumpcore:PROJECT_SPEC recompile and dump a core file for faster startup'
  24. 'diff:show local changes (for all version-controlled projects)'
  25. 'check-urls:compared installed repository urls agains current locations'
  26. 'clean-links:remove broken symlinks in systems/'
  27. 'rebuild-links:removes and adds .asd file symlinks for all projects'
  28. 'update-missing:download only projects not present yet'
  29. 'register-asd:PROJECT add .asd file symlinks for PROJECT'
  30. 'compile-implementation:sbcl [XC_HOST] compile SBCL'
  31. 'clean:[PROJECT] delete all compiled object files [in source/PROJECT]'
  32. 'trash:PROJECT move source/PROJECT to trash/'
  33. 'mrproper:trash all projects'
  34. 'slime:run the Superior Lisp Interaction Mode in a fresh Emacs'
  35. 'lisp:run Lisp in the terminal (using sbcl.core)'
  36. 'preloaded:run Lisp in the terminal (using monster.core)'
  37. 'slime-configuration:print .emacs excerpt for slime'
  38. 'make-project:NAME set up an new, empty project'
  39. 'record-dependencies:rebuild dependency information file'
  40. )
  41. _describe -t commands 'clbuild command' commands && return 0
  42. }
  43.  
  44. (( $+functions[_clbuild-list] )) ||
  45. _clbuild-list () {
  46. local curcontext=$curcontext state line
  47. typeset -A opt_args
  48. _arguments ':pattern:' && ret=0
  49. }
  50.  
  51. (( $+functions[_clbuild-update] )) ||
  52. _clbuild-update () {
  53. local curcontext=$curcontext state line
  54. typeset -A opt_args
  55. _arguments \
  56. '--dependencies=-[download/update this project]' \
  57. '--no-dependencies=-[download/update this project]' \
  58. '--resume[only projects that a previous update run failed to fetch]' \
  59. ':project:__clbuild_projects' \
  60. && ret=0
  61. }
  62.  
  63. (( $+functions[__clbuild_file_projects] )) ||
  64. __clbuild_file_projects () {
  65. local f="$1"
  66. print ${(@)${${(@f)"$(<${f})"}:#\#*}%% *}
  67. }
  68.  
  69. (( $+functions[__clbuild_projects] )) ||
  70. __clbuild_projects () {
  71. __clbuild_projects_1
  72. __clbuild_project_groups
  73. }
  74.  
  75. (( $+functions[__clbuild_projects_1] )) ||
  76. __clbuild_projects_1 () {
  77. local -a fs ps
  78.  
  79. fs=(projects wnpp-projects my-projects implementations)
  80. for f in $fs; do
  81. if [[ -f ${clbuild_dir}/$f ]]; then
  82. ps=($ps $(__clbuild_file_projects "${clbuild_dir}/$f"))
  83. fi
  84. done
  85. : ${(A)ps::=${(u)ps}}
  86.  
  87. local expl
  88. _wanted projects expl project compadd $* - $ps
  89. }
  90.  
  91. (( $+functions[__clbuild_project_groups] )) ||
  92. __clbuild_project_groups () {
  93. local expl
  94. _wanted -V project-groups expl project-group compadd $* - \
  95. --all-projects --main-projects --wnpp-projects --installed
  96. }
  97.  
  98. (( $+functions[__clbuild_def_project_fn] )) ||
  99. __clbuild_def_project_fn () {
  100. local name="$1"
  101. eval ${"$(<=(cat <<"EOT"
  102. (( $+functions[$name] )) ||
  103. $name () {
  104. local curcontext=$curcontext state line
  105. typeset -A opt_args
  106. _arguments ':project:__clbuild_projects_1' && ret=0
  107. }
  108. EOT
  109. ))"//\$name/$name}
  110. }
  111. {
  112. local fn
  113. for fn in skip recompile dumpcore register-asd clean trash \
  114. recompile show; do
  115. __clbuild_def_project_fn _clbuild-$fn
  116. done
  117. }
  118.  
  119. local state line context ret=1 curcontext
  120. typeset -A opt_args
  121. _arguments -C \
  122. '--help[display help messsage]' \
  123. '--long-help[display help message]' \
  124. '--implementation=-[specify lisp implementation]' \
  125. '*::arg:->cmd_or_options' && ret=0
  126. case $state in
  127. (cmd_or_options)
  128. if ((CURRENT == 1)); then
  129. _call_function ret __clbuild_commands
  130. else
  131. (( $+functions[_clbuild-$words[1]] )) && {
  132. curcontext="${curcontext%:*:*}:clbuild-$words[1]:"
  133. _call_function ret _clbuild-$words[1]
  134. }
  135. fi
  136. ;;
  137. esac
  138. return ret
  139. }
  140.  
  141. _clbuild
Add Comment
Please, Sign In to add comment