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.

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