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.

288 lines
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. '(--include)--include[Directories containing additional include files]:includes' \
  60. '(-v --verbose)'{-v,--verbose}'[Print coverage analysis]' \
  61. '(--auto_compile)--auto_compile' \
  62. && ret=0
  63. ;;
  64. (deps)
  65. _message 'no more arguments' && ret=0
  66. ;;
  67. (dialyzer)
  68. _arguments \
  69. '(-u --update-plt)'{-u, --update-plt}'[Enable updating the PLT.]' \
  70. '(-s --succ-typings)'{-s, --succ-typings}'[Enable success typing analysis.]' \
  71. && ret=0
  72. ;;
  73. (do)
  74. _message 'rebar do' && ret=0
  75. ;;
  76. (edoc)
  77. _message 'rebar edoc' && ret=0
  78. ;;
  79. (escriptize)
  80. _message 'rebar escriptize' && ret=0
  81. ;;
  82. (eunit)
  83. _arguments \
  84. '(--app)--app[Comma separated list of application test suites to run]:suites' \
  85. '(--application)--application[Comma separated list of application test suites to run]:applications' \
  86. '(-c --cover)'{-c,--cover}'[Generate cover data]' \
  87. '(-d --dir)'{-d,--dir}'[Comma separated list of dirs to load tests from]:dirs' \
  88. '(-e --error_on_warning)'{-e,--error_on_warning}'[Error on invalid test specifications instead of warning]' \
  89. '(-f --file)'{-f,--file}'[Comma separated list of files to load tests from]:files' \
  90. '(-m --module)'{-m,--module}'[Comma separated list of modules to load tests from]:modules' \
  91. '(-s --suite)'{-s,--suite}'[Comma separated list of modules to load tests from]:modules' \
  92. '(-g --generator)'{-g,--generator}'[Comma separated list of generators (the format is `module:function`) to load tests from.]:{generator, Module, Function}' \
  93. '(-v --verbose)'{-v,--verbose}'[Verbose output]' \
  94. && ret=0
  95. ;;
  96. (help)
  97. _arguments '1: :_rebar3_tasks' && ret=0
  98. ;;
  99. (new)
  100. _arguments \
  101. '1:type:(app cmake escript lib plugin release)' \
  102. '2:name:' \
  103. '(-f --force)'{-f,--force}'[ overwrite existing files]' \
  104. && ret=0
  105. ;;
  106. (path)
  107. _arguments \
  108. '(--app)--app[Comma separated list of applications to return paths for.]:apps' \
  109. '(--base)--base[Return the `base` path of the current profile.]' \
  110. '(--bin)--bin[Return the `bin` path of the current profile.]' \
  111. '(--ebin)--ebin[Return all `ebin` paths of the current profile`s applications.]' \
  112. '(--lib)--lib[Return the `lib` path of the current profile.]' \
  113. '(--priv)--priv[Return the `priv` path of the current profile`s applications.]' \
  114. '(-s --separator)--separator[In case of multiple return paths, the separator character to use to join them.]' \
  115. && ret=0
  116. ;;
  117. (pkgs)
  118. _message 'List information for a given package.' && ret=0
  119. ;;
  120. (plugins)
  121. _arguments \
  122. '1:type:(list upgrade)' \
  123. && ret=0
  124. ;;
  125. (release)
  126. _arguments \
  127. '(-n --relname)'{-n,--relname}'[Specify the name for the release that will be generated.]:relname' \
  128. '(-v --relvsn)'{-n,--relname}'[Specify the version for the release.]:relvsn' \
  129. '(-g --goal)'{-g,--goal}'[Specify a target constraint on the system. These are usually the OTP.]:goal' \
  130. '(-u --upfrom)'{-u,--upfrom}'[Only valid with relup target, specify the release to upgrade from.]:upfrom' \
  131. '(-o --output-dir)'{-o,--output-dir}'[The output directory for the release. This is ./ by default.]:out directory:_files -/' \
  132. '(-l --lib-dir)'{-l,--output-dir}'[Additional dir that should be searched for OTP Apps]:lib directory:_files -/' \
  133. '(-p --path)'{-p,--path}'[Additional dir to add to the code path]:path directory:_files -/' \
  134. '(--default-libs)--default-libs[Whether to use the default system added lib dirs]:default libs:(true false)' \
  135. '(-V --verbose)'{-V,--verbose}'[Verbosity level, maybe between 0 and 3 ,default: 2]:verbosity level:(0 1 2 3)' \
  136. '(-d --dev-mode)'{-d,--dev-mode}'[Symlink the applications and configuration into the release instead of copying]' \
  137. '(-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]' \
  138. '(-a --override)'{-a,--override}'[Provide an app name and a directory to override in the form <appname>:<app directory>]:override' \
  139. '(-c --config)'{-c,--config}'[The path to a config file]:config file:_files ' \
  140. '(--overlay_vars)--overlay_vars[Path to a file of overlay variables]:overlay variables file:_files' \
  141. '(--vm_args)--vm_args[Path to a file to use for vm.args]:vm args file:_files' \
  142. '(--sys_config)--sys_config[Path to a file to use for sys.config]:sys config file:_files' \
  143. '(--system_libs)--system_libs[Path to dir of Erlang system libs]:system libs:_files -/' \
  144. '(--version)--version[Print relx version]' \
  145. '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \
  146. && ret=0
  147. ;;
  148. (relup)
  149. _arguments \
  150. '(-n --relname)'{-n,--relname}'[Specify the name for the release that will be generated.]:relname' \
  151. '(-v --relvsn)'{-n,--relname}'[Specify the version for the release.]:relvsn' \
  152. '(-g --goal)'{-g,--goal}'[Specify a target constraint on the system. These are usually the OTP.]:goal' \
  153. '(-u --upfrom)'{-u,--upfrom}'[Only valid with relup target, specify the release to upgrade from.]:upfrom' \
  154. '(-o --output-dir)'{-o,--output-dir}'[The output directory for the release. This is ./ by default.]:out directory:_files -/' \
  155. '(-l --lib-dir)'{-l,--output-dir}'[Additional dir that should be searched for OTP Apps]:lib directory:_files -/' \
  156. '(-p --path)'{-p,--path}'[Additional dir to add to the code path]:path directory:_files -/' \
  157. '(--default-libs)--default-libs[Whether to use the default system added lib dirs]:default libs:(true false)' \
  158. '(-V --verbose)'{-V,--verbose}'[Verbosity level, maybe between 0 and 3 ,default: 2]:verbosity level:(0 1 2 3)' \
  159. '(-d --dev-mode)'{-d,--dev-mode}'[Symlink the applications and configuration into the release instead of copying]' \
  160. '(-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]' \
  161. '(-a --override)'{-a,--override}'[Provide an app name and a directory to override in the form <appname>:<app directory>]:override' \
  162. '(-c --config)'{-c,--config}'[The path to a config file]:config file:_files ' \
  163. '(--overlay_vars)--overlay_vars[Path to a file of overlay variables]:overlay variables file:_files' \
  164. '(--vm_args)--vm_args[Path to a file to use for vm.args]:vm args file:_files' \
  165. '(--sys_config)--sys_config[Path to a file to use for sys.config]:sys config file:_files' \
  166. '(--system_libs)--system_libs[Path to dir of Erlang system libs]:system libs:_files -/' \
  167. '(--version)--version[Print relx version]' \
  168. '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \
  169. && ret=0
  170. ;;
  171. (report)
  172. _arguments '1: :_rebar3_tasks' && ret=0
  173. ;;
  174. (shell)
  175. _message 'Start a shell with project and deps preloaded' && ret=0
  176. ;;
  177. (tar)
  178. _arguments \
  179. '(-n --relname)'{-n,--relname}'[Specify the name for the release that will be generated.]:relname' \
  180. '(-v --relvsn)'{-n,--relname}'[Specify the version for the release.]:relvsn' \
  181. '(-g --goal)'{-g,--goal}'[Specify a target constraint on the system. These are usually the OTP.]:goal' \
  182. '(-u --upfrom)'{-u,--upfrom}'[Only valid with relup target, specify the release to upgrade from.]:upfrom' \
  183. '(-o --output-dir)'{-o,--output-dir}'[The output directory for the release. This is ./ by default.]:out directory:_files -/' \
  184. '(-l --lib-dir)'{-l,--output-dir}'[Additional dir that should be searched for OTP Apps]:lib directory:_files -/' \
  185. '(-p --path)'{-p,--path}'[Additional dir to add to the code path]:path directory:_files -/' \
  186. '(--default-libs)--default-libs[Whether to use the default system added lib dirs]:default libs:(true false)' \
  187. '(-V --verbose)'{-V,--verbose}'[Verbosity level, maybe between 0 and 3 ,default: 2]:verbosity level:(0 1 2 3)' \
  188. '(-d --dev-mode)'{-d,--dev-mode}'[Symlink the applications and configuration into the release instead of copying]' \
  189. '(-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]' \
  190. '(-a --override)'{-a,--override}'[Provide an app name and a directory to override in the form <appname>:<app directory>]:override' \
  191. '(-c --config)'{-c,--config}'[The path to a config file]:config file:_files ' \
  192. '(--overlay_vars)--overlay_vars[Path to a file of overlay variables]:overlay variables file:_files' \
  193. '(--vm_args)--vm_args[Path to a file to use for vm.args]:vm args file:_files' \
  194. '(--sys_config)--sys_config[Path to a file to use for sys.config]:sys config file:_files' \
  195. '(--system_libs)--system_libs[Path to dir of Erlang system libs]:system libs:_files -/' \
  196. '(--version)--version[Print relx version]' \
  197. '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \
  198. && ret=0
  199. ;;
  200. (tree)
  201. _arguments \
  202. '(-v --verbose)'{-v,--verbose}'[Print repo and branch/tag/ref for git and hg deps]' \
  203. && ret=0
  204. ;;
  205. (unlock)
  206. _arguments \
  207. '*: :_rebar3_list_deps' \
  208. && ret=0
  209. ;;
  210. (unstable)
  211. _arguments \
  212. '*: :(install upgrade)' \
  213. && ret=0
  214. ;;
  215. (update)
  216. _message 'rebar update' && ret=0
  217. ;;
  218. (upgrade)
  219. _arguments \
  220. '*: :_rebar3_list_deps' \
  221. && ret=0
  222. ;;
  223. (version)
  224. _message 'rebar version' && ret=0
  225. ;;
  226. (xref)
  227. _message 'rebar xref' && ret=0
  228. esac
  229. esac
  230. }
  231. (( $+functions[_rebar3_tasks] )) ||
  232. _rebar3_tasks() {
  233. local tasks; tasks=(
  234. 'as:Higher order provider for running multiple tasks in a sequence as a certain profiles.'
  235. 'clean:Remove compiled beam files from apps.'
  236. 'compile:Compile apps .app.src and .erl files.'
  237. 'cover:Perform coverage analysis.'
  238. 'ct:Run Common Tests.'
  239. 'deps:List dependencies.'
  240. 'dialyzer:Run the Dialyzer analyzer on the project.'
  241. 'do:Higher order provider for running multiple tasks in a sequence.'
  242. 'edoc:Generate documentation using edoc.'
  243. 'escriptize:Generate escript archive.'
  244. 'eunit:Run EUnit Tests.'
  245. 'help:Display a list of tasks or help for a given task or subtask.'
  246. 'new:Create new project from templates.'
  247. 'pkgs:List information for a given package.'
  248. 'plugins:List or upgrade plugins.'
  249. 'release:Build release of project.'
  250. 'relup:Create relup from 2 releases.'
  251. 'report:Provide a crash report to be sent to the rebar3 issues page.'
  252. 'shell:Run shell with project apps and deps in path.'
  253. 'tar:Tar archive of release built of project.'
  254. 'tree:Print dependency tree.'
  255. 'unlock:Unlock dependencies.'
  256. 'unstable:Namespace providing commands that are still in flux.'
  257. 'update:Update package index.'
  258. 'upgrade:Upgrade dependencies.'
  259. 'version:Print version for rebar and current Erlang.'
  260. 'xref:Run cross reference analysis.'
  261. )
  262. _describe -t tasks 'rebar3 tasks' tasks "$@"
  263. }
  264. (( $+functions[_rebar3_list_deps] )) ||
  265. _rebar3_list_deps() {
  266. local -a cmd packages deps_long
  267. deps_long=($PWD/_build/default/lib/*(/))
  268. packages=( ${${deps_long#$PWD/_build/default/lib/}%-*-*} )
  269. compadd "$@" -a packages
  270. }
  271. _rebar3 "$@"
  272. # Local variables:
  273. # mode: shell-script
  274. # sh-basic-offset: 2
  275. # sh-indent-comment: t
  276. # indent-tabs-mode: nil
  277. # End:
  278. # ex: sw=2 ts=2 et filetype=sh