You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

286 line
17 KiB

  1. #compdef rebar3
  2. _rebar3 () {
  3. typeset -A opt_args
  4. local curcontext="$curcontext" state line
  5. local ret=1
  6. _arguments -C \
  7. '1: :_rebar3_tasks' \
  8. '*::arg:->args' \
  9. && ret=0
  10. case $state in
  11. (args)
  12. curcontext="${curcontext%:*:*}:rebar-task-$words[1]:"
  13. case $line[1] in
  14. (as)
  15. _arguments \
  16. '1:name' \
  17. '2: :_rebar3_tasks' \
  18. && ret=0
  19. ;;
  20. (clean)
  21. _arguments \
  22. '(-a --all)'{-a,--all}'[Clean all apps include deps.]' \
  23. && ret=0
  24. ;;
  25. (compile)
  26. _message 'no more arguments' && ret=0
  27. ;;
  28. (cover)
  29. _arguments \
  30. '(-r --reset)'{-r,--reset}'[Reset all coverdata.]' \
  31. '(-v --verbose)'{-v,--verbose}'[Print coverage analysis.]' \
  32. && ret=0
  33. ;;
  34. (ct)
  35. _arguments \
  36. '(--dir)--dir[List of additional directories containing test suites]:test directory:_files -/' \
  37. '(--suite)--suite[List of test suites to run]:suites' \
  38. '(--group)--group[List of test groups to run]:groups' \
  39. '(--case)--case[List of test cases to run]:cases' \
  40. '(--label)--label[Test label]:label' \
  41. '(--config)--config[List of config files]:config files:_files' \
  42. '(--allow_user_terms)--allow_user_terms' \
  43. '(--logdir)--logdir[Log folder]:log folder:_files -/' \
  44. '(--logopts)--logopts' \
  45. '(--verbosity)--verbosity[Verbosity]:verbosity' \
  46. '(-c --cover)'{-c,--cover}'[Generate cover data]' \
  47. '(--repeat)--repeat[How often to repeat tests]:repeat test count' \
  48. '(--duration)--duration[Max runtime (format: HHMMSS)]:max run time' \
  49. '(--until)--until[Run until (format: HHMMSS)]:run until time' \
  50. '(--force_stop)--force_stop[Force stop on test timeout]:skip_rest' \
  51. '(--basic_html)--basic_html[Show basic HTML]' \
  52. '(--stylesheet)--stylesheet[Stylesheet to use for test results]:stylesheet:_files' \
  53. '(--decrypt_key)--decrypt_key[Path to key for decrypting config]:decrypt key:_files' \
  54. '(--decrypt_file)--decrypt_file[Path to file containing key for decrypting config]:decrypt file:_files' \
  55. '(--abort_if_missing_suites)--abort_if_missing_suites[Abort if suites are missing]:abort missing suites:(true false)' \
  56. '(--multiply_timetraps)--multiply_timetraps' \
  57. '(--scale_timetraps)--scale_timetraps' \
  58. '(--create_priv_dir)--create_priv_dir' \
  59. '(-v --verbose)'{-v,--verbose}'[Print coverage analysis]' \
  60. '(--auto_compile)--auto_compile' \
  61. && ret=0
  62. ;;
  63. (deps)
  64. _message 'no more arguments' && ret=0
  65. ;;
  66. (dialyzer)
  67. _arguments \
  68. '(-u --update-plt)'{-u, --update-plt}'[Enable updating the PLT.]' \
  69. '(-s --succ-typings)'{-s, --succ-typings}'[Enable success typing analysis.]' \
  70. && ret=0
  71. ;;
  72. (do)
  73. _message 'rebar do' && ret=0
  74. ;;
  75. (edoc)
  76. _message 'rebar edoc' && ret=0
  77. ;;
  78. (escriptize)
  79. _message 'rebar escriptize' && ret=0
  80. ;;
  81. (eunit)
  82. _arguments \
  83. '(--app)--app[Comma separated list of application test suites to run]:suites' \
  84. '(--application)--application[Comma separated list of application test suites to run]:applications' \
  85. '(-c --cover)'{-c,--cover}'[Generate cover data]' \
  86. '(-d --dir)'{-d,--dir}'[Comma separated list of dirs to load tests from]:dirs' \
  87. '(-e --error_on_warning)'{-e,--error_on_warning}'[Error on invalid test specifications instead of warning]' \
  88. '(-f --file)'{-f,--file}'[Comma separated list of files to load tests from]:files' \
  89. '(-m --module)'{-m,--module}'[Comma separated list of modules to load tests from]:modules' \
  90. '(-s --suite)'{-s,--suite}'[Comma separated list of modules to load tests from]:modules' \
  91. '(-v --verbose)'{-v,--verbose}'[Verbose output]' \
  92. && ret=0
  93. ;;
  94. (help)
  95. _arguments '1: :_rebar3_tasks' && ret=0
  96. ;;
  97. (new)
  98. _arguments \
  99. '1:type:(app cmake escript lib plugin release)' \
  100. '2:name:' \
  101. '(-f --force)'{-f,--force}'[ overwrite existing files]' \
  102. && ret=0
  103. ;;
  104. (path)
  105. _arguments \
  106. '(--app)--app[Comma seperated list of applications to return paths for.]:apps' \
  107. '(--base)--base[Return the `base` path of the current profile.]' \
  108. '(--bin)--bin[Return the `bin` path of the current profile.]' \
  109. '(--ebin)--ebin[Return all `ebin` paths of the current profile`s applications.]' \
  110. '(--lib)--lib[Return the `lib` path of the current profile.]' \
  111. '(--priv)--priv[Return the `priv` path of the current profile`s applications.]' \
  112. '(-s --separator)--separator[In case of multiple return paths, the separator character to use to join them.]' \
  113. && ret=0
  114. ;;
  115. (pkgs)
  116. _message 'List available packages.' && ret=0
  117. ;;
  118. (plugins)
  119. _arguments \
  120. '1:type:(list upgrade)' \
  121. && ret=0
  122. ;;
  123. (release)
  124. _arguments \
  125. '(-n --relname)'{-n,--relname}'[Specify the name for the release that will be generated.]:relname' \
  126. '(-v --relvsn)'{-n,--relname}'[Specify the version for the release.]:relvsn' \
  127. '(-g --goal)'{-g,--goal}'[Specify a target constraint on the system. These are usually the OTP.]:goal' \
  128. '(-u --upfrom)'{-u,--upfrom}'[Only valid with relup target, specify the release to upgrade from.]:upfrom' \
  129. '(-o --output-dir)'{-o,--output-dir}'[The output directory for the release. This is ./ by default.]:out directory:_files -/' \
  130. '(-l --lib-dir)'{-l,--output-dir}'[Additional dir that should be searched for OTP Apps]:lib directory:_files -/' \
  131. '(-p --path)'{-p,--path}'[Additional dir to add to the code path]:path directory:_files -/' \
  132. '(--default-libs)--default-libs[Whether to use the default system added lib dirs]:default libs:(true false)' \
  133. '(-V --verbose)'{-V,--verbose}'[Verbosity level, maybe between 0 and 3 ,default: 2]:verbosity level:(0 1 2 3)' \
  134. '(-d --dev-mode)'{-d,--dev-mode}'[Symlink the applications and configuration into the release instead of copying]' \
  135. '(-i --include-erts)'{-i,--dev-mode}'[If true include a copy of erts used to build with, if a path include erts at that path. If false, do not include erts]' \
  136. '(-a --override)'{-a,--override}'[Provide an app name and a directory to override in the form <appname>:<app directory>]:override' \
  137. '(-c --config)'{-c,--config}'[The path to a config file]:config file:_files ' \
  138. '(--overlay_vars)--overlay_vars[Path to a file of overlay variables]:overlay variables file:_files' \
  139. '(--vm_args)--vm_args[Path to a file to use for vm.args]:vm args file:_files' \
  140. '(--sys_config)--sys_config[Path to a file to use for sys.config]:sys config file:_files' \
  141. '(--system_libs)--system_libs[Path to dir of Erlang system libs]:system libs:_files -/' \
  142. '(--version)--version[Print relx version]' \
  143. '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \
  144. && ret=0
  145. ;;
  146. (relup)
  147. _arguments \
  148. '(-n --relname)'{-n,--relname}'[Specify the name for the release that will be generated.]:relname' \
  149. '(-v --relvsn)'{-n,--relname}'[Specify the version for the release.]:relvsn' \
  150. '(-g --goal)'{-g,--goal}'[Specify a target constraint on the system. These are usually the OTP.]:goal' \
  151. '(-u --upfrom)'{-u,--upfrom}'[Only valid with relup target, specify the release to upgrade from.]:upfrom' \
  152. '(-o --output-dir)'{-o,--output-dir}'[The output directory for the release. This is ./ by default.]:out directory:_files -/' \
  153. '(-l --lib-dir)'{-l,--output-dir}'[Additional dir that should be searched for OTP Apps]:lib directory:_files -/' \
  154. '(-p --path)'{-p,--path}'[Additional dir to add to the code path]:path directory:_files -/' \
  155. '(--default-libs)--default-libs[Whether to use the default system added lib dirs]:default libs:(true false)' \
  156. '(-V --verbose)'{-V,--verbose}'[Verbosity level, maybe between 0 and 3 ,default: 2]:verbosity level:(0 1 2 3)' \
  157. '(-d --dev-mode)'{-d,--dev-mode}'[Symlink the applications and configuration into the release instead of copying]' \
  158. '(-i --include-erts)'{-i,--dev-mode}'[If true include a copy of erts used to build with, if a path include erts at that path. If false, do not include erts]' \
  159. '(-a --override)'{-a,--override}'[Provide an app name and a directory to override in the form <appname>:<app directory>]:override' \
  160. '(-c --config)'{-c,--config}'[The path to a config file]:config file:_files ' \
  161. '(--overlay_vars)--overlay_vars[Path to a file of overlay variables]:overlay variables file:_files' \
  162. '(--vm_args)--vm_args[Path to a file to use for vm.args]:vm args file:_files' \
  163. '(--sys_config)--sys_config[Path to a file to use for sys.config]:sys config file:_files' \
  164. '(--system_libs)--system_libs[Path to dir of Erlang system libs]:system libs:_files -/' \
  165. '(--version)--version[Print relx version]' \
  166. '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \
  167. && ret=0
  168. ;;
  169. (report)
  170. _arguments '1: :_rebar3_tasks' && ret=0
  171. ;;
  172. (shell)
  173. _message 'Start a shell with project and deps preloaded' && ret=0
  174. ;;
  175. (tar)
  176. _arguments \
  177. '(-n --relname)'{-n,--relname}'[Specify the name for the release that will be generated.]:relname' \
  178. '(-v --relvsn)'{-n,--relname}'[Specify the version for the release.]:relvsn' \
  179. '(-g --goal)'{-g,--goal}'[Specify a target constraint on the system. These are usually the OTP.]:goal' \
  180. '(-u --upfrom)'{-u,--upfrom}'[Only valid with relup target, specify the release to upgrade from.]:upfrom' \
  181. '(-o --output-dir)'{-o,--output-dir}'[The output directory for the release. This is ./ by default.]:out directory:_files -/' \
  182. '(-l --lib-dir)'{-l,--output-dir}'[Additional dir that should be searched for OTP Apps]:lib directory:_files -/' \
  183. '(-p --path)'{-p,--path}'[Additional dir to add to the code path]:path directory:_files -/' \
  184. '(--default-libs)--default-libs[Whether to use the default system added lib dirs]:default libs:(true false)' \
  185. '(-V --verbose)'{-V,--verbose}'[Verbosity level, maybe between 0 and 3 ,default: 2]:verbosity level:(0 1 2 3)' \
  186. '(-d --dev-mode)'{-d,--dev-mode}'[Symlink the applications and configuration into the release instead of copying]' \
  187. '(-i --include-erts)'{-i,--dev-mode}'[If true include a copy of erts used to build with, if a path include erts at that path. If false, do not include erts]' \
  188. '(-a --override)'{-a,--override}'[Provide an app name and a directory to override in the form <appname>:<app directory>]:override' \
  189. '(-c --config)'{-c,--config}'[The path to a config file]:config file:_files ' \
  190. '(--overlay_vars)--overlay_vars[Path to a file of overlay variables]:overlay variables file:_files' \
  191. '(--vm_args)--vm_args[Path to a file to use for vm.args]:vm args file:_files' \
  192. '(--sys_config)--sys_config[Path to a file to use for sys.config]:sys config file:_files' \
  193. '(--system_libs)--system_libs[Path to dir of Erlang system libs]:system libs:_files -/' \
  194. '(--version)--version[Print relx version]' \
  195. '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \
  196. && ret=0
  197. ;;
  198. (tree)
  199. _arguments \
  200. '(-v --verbose)'{-v,--verbose}'[Print repo and branch/tag/ref for git and hg deps]' \
  201. && ret=0
  202. ;;
  203. (unlock)
  204. _arguments \
  205. '*: :_rebar3_list_deps' \
  206. && ret=0
  207. ;;
  208. (unstable)
  209. _arguments \
  210. '*: :(install upgrade)' \
  211. && ret=0
  212. ;;
  213. (update)
  214. _message 'rebar update' && ret=0
  215. ;;
  216. (upgrade)
  217. _arguments \
  218. '*: :_rebar3_list_deps' \
  219. && ret=0
  220. ;;
  221. (version)
  222. _message 'rebar version' && ret=0
  223. ;;
  224. (xref)
  225. _message 'rebar xref' && ret=0
  226. esac
  227. esac
  228. }
  229. (( $+functions[_rebar3_tasks] )) ||
  230. _rebar3_tasks() {
  231. local tasks; tasks=(
  232. 'as:Higher order provider for running multiple tasks in a sequence as a certain profiles.'
  233. 'clean:Remove compiled beam files from apps.'
  234. 'compile:Compile apps .app.src and .erl files.'
  235. 'cover:Perform coverage analysis.'
  236. 'ct:Run Common Tests.'
  237. 'deps:List dependencies.'
  238. 'dialyzer:Run the Dialyzer analyzer on the project.'
  239. 'do:Higher order provider for running multiple tasks in a sequence.'
  240. 'edoc:Generate documentation using edoc.'
  241. 'escriptize:Generate escript archive.'
  242. 'eunit:Run EUnit Tests.'
  243. 'help:Display a list of tasks or help for a given task or subtask.'
  244. 'new:Create new project from templates.'
  245. 'pkgs:List available packages.'
  246. 'plugins:List or upgrade plugins.'
  247. 'release:Build release of project.'
  248. 'relup:Create relup from 2 releases.'
  249. 'report:Provide a crash report to be sent to the rebar3 issues page.'
  250. 'shell:Run shell with project apps and deps in path.'
  251. 'tar:Tar archive of release built of project.'
  252. 'tree:Print dependency tree.'
  253. 'unlock:Unlock dependencies.'
  254. 'unstable:Namespace providing commands that are still in flux.'
  255. 'update:Update package index.'
  256. 'upgrade:Upgrade dependencies.'
  257. 'version:Print version for rebar and current Erlang.'
  258. 'xref:Run cross reference analysis.'
  259. )
  260. _describe -t tasks 'rebar3 tasks' tasks "$@"
  261. }
  262. (( $+functions[_rebar3_list_deps] )) ||
  263. _rebar3_list_deps() {
  264. local -a cmd packages deps_long
  265. deps_long=($PWD/_build/default/lib/*(/))
  266. packages=( ${${deps_long#$PWD/_build/default/lib/}%-*-*} )
  267. compadd "$@" -a packages
  268. }
  269. _rebar3 "$@"
  270. # Local variables:
  271. # mode: shell-script
  272. # sh-basic-offset: 2
  273. # sh-indent-comment: t
  274. # indent-tabs-mode: nil
  275. # End:
  276. # ex: sw=2 ts=2 et filetype=sh