Skip to content
This repository
Browse code

Merge pull request #224 from supki/cabal-completion-update

Update _cabal completion
commit 059df4ec0594c74cb2d4a86a7cb928a4f674df82 2 parents 15cb792 + d34904f
Hideo Hattori hhatto authored

Showing 1 changed file with 92 additions and 16 deletions. Show diff stats Hide diff stats

  1. +92 16 src/_cabal
108 src/_cabal
@@ -50,9 +50,14 @@ _cabal ()
50 50
51 51 if (( $#WORDS == 1 )); then
52 52 _arguments \
53   - {-h,--help}'[Show help]' \
54   - {-V,--version}'[Print version information]' \
55   - '--numeric-version[Print just the version number]' \
  53 + {-h,--help}'[show help]' \
  54 + {-V,--version}'[print version information]' \
  55 + '--numeric-version[print just the version number]' \
  56 + '--config-file=[set an alternate location for the config file]:config file:_files' \
  57 + '--sandbox-config-file=[set an alternate location for the sandbox config file]:config file:_files' \
  58 + '--require-sandbox[enable requiring the presence of a sandbox for sandbox-aware commands]' \
  59 + '--no-require-sandbox[disable requiring the presence of a sandbox for sandbox-aware commands]' \
  60 + '--ignore-sandbox[ignore any existing sandbox]' \
56 61 '*::command:_cabal_command'
57 62 else
58 63 _arguments '*::command:_cabal_command'
@@ -68,6 +73,7 @@ _cabal_command ()
68 73 'list:list packages matching a search string'
69 74 'info:display detailed information about a particular package'
70 75 'fetch:downloads packages for later installation'
  76 + 'freeze:freeze dependencies'
71 77 "get:get a package's source code"
72 78 'check:check the package for common mistakes'
73 79 'sdist:generate a source distribution file (.tar.gz)'
@@ -76,11 +82,12 @@ _cabal_command ()
76 82 'run:runs the compiled executable'
77 83 'init:interactively create a .cabal file'
78 84 'configure:prepare to build the package'
79   - 'build:make this package ready for installation'
  85 + 'build:compile all targets or specific targets'
80 86 'repl:open an interpreter session for the given target'
81 87 'sandbox:create/modify/delete a sandbox'
82   - 'copy:copy the files into the install locations'
83 88 'haddock:generate Haddock HTML documentation'
  89 + 'exec:run a command with the cabal environment'
  90 + 'copy:copy the files into the install locations'
84 91 'clean:clean up after a build'
85 92 'hscolour:generate HsColour colourised code, in HTML format'
86 93 'register:register this package with the compiler'
@@ -126,6 +133,7 @@ _cabal_bench ()
126 133 '--benchmark-options=[give extra options to benchmark executables]' \
127 134 '--benchmark-option=[give an extra option to benchmark executables (no need to quote options containing spaces)]' \
128 135 {-j,--jobs=}'[run NUM jobs simultaneously]' \
  136 + $_cabal_programs \
129 137 "--only[don't reinstall add-source dependencies (sandbox-only)]"
130 138 }
131 139
@@ -156,6 +164,9 @@ _cabal_clean ()
156 164
157 165 _cabal_configure ()
158 166 {
  167 + local context state state_descr line
  168 + typeset -A opt_args
  169 +
159 170 _arguments \
160 171 {-h,--help}'[show help]' \
161 172 {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \
@@ -166,6 +177,7 @@ _cabal_configure ()
166 177 '--lhc[compile with LHC]' \
167 178 '--hugs[compile with Hugs]' \
168 179 '--uhc[compile with UHC]' \
  180 + '--haskell-suite[compile with a haskell-suite compiler]' \
169 181 {-w,--with-compiler=}'[give the path to a particular compiler]:file:_files' \
170 182 '--with-hc-pkg=[give the path to the package tool]:file:_files' \
171 183 '--prefix=[take this prefix in preparation of installation]:directory:_files -/' \
@@ -203,7 +215,7 @@ _cabal_configure ()
203 215 '--configure-option=[extra option for configure]' \
204 216 '--user[enable doing a per-user installation]' \
205 217 '--global[disable doing a per-user installation]' \
206   - '--package-db=[use a specific package database]:files:_files' \
  218 + '--package-db=[use a given package database]:: :->default-db-or-filepath' \
207 219 {-f,--flags=}'[force values for the given flags]:flags:' \
208 220 '--extra-include-dirs=[a list of directories to search for header files]:directory:_files -/' \
209 221 '--extra-lib-dirs=[a list of directories to search for externallibraries]:directory:_files -/' \
@@ -218,7 +230,16 @@ _cabal_configure ()
218 230 '--cabal-lib-version=[select which version of the Cabal lib to use]' \
219 231 '--constraint=[a list of additional constraints on the dependencies]' \
220 232 '--preference=[specify preferences on the version of a package]' \
221   - '--solver=[select dependency solver to use]:solver:(topdown modular choose)'
  233 + '--solver=[select dependency solver to use]:solver:(topdown modular choose)' \
  234 + '--allow-newer=[ignore upper bounds in dependencies on some or all packages]'
  235 +
  236 + case $state in
  237 + (default-db-or-filepath)
  238 + _alternative \
  239 + ':default db:(global user clear)' \
  240 + ':filepath:_files'
  241 + ;;
  242 + esac
222 243 }
223 244
224 245 _cabal_copy ()
@@ -230,6 +251,13 @@ _cabal_copy ()
230 251 '--destdir=[directory to copy files to]:directory:_files -/'
231 252 }
232 253
  254 +_cabal_exec ()
  255 +{
  256 + _arguments \
  257 + {-h,--help}'[show help]' \
  258 + {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)'
  259 +}
  260 +
233 261 _cabal_fetch ()
234 262 {
235 263 _arguments \
@@ -245,12 +273,24 @@ _cabal_fetch ()
245 273 '*:package:_cabal_list_packages'
246 274 }
247 275
  276 +_cabal_freeze ()
  277 +{
  278 + _arguments \
  279 + {-h,--help}'[show help]' \
  280 + {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \
  281 + '--dry-run[do not freeze anything, only print what would be frozen]' \
  282 + '--solver=[select dependency solver to use]:solver:(topdown modular choose)]' \
  283 + '--max-backjumps=[maximum number of backjumps allowed while solving dependencies]' \
  284 + '--reorder-goals[try to reorder goals according to certain heuristics]' \
  285 + '--shadow-installed-packages[if multiple package instances of the same version are installed, treat all but one as shadowed]'
  286 +}
  287 +
248 288 _cabal_get ()
249 289 {
250 290 _arguments \
251 291 {-h,--help}'[show help]' \
252 292 {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \
253   - {-d,--destdir=}'[where to unpack the packages]:directory:_files -/' \
  293 + {-d-,--destdir=}'[where to unpack the packages]:directory:_files -/' \
254 294 {-s,--source-repository=}"[copy the package's source repository]" \
255 295 '--pristine[unpack the original pristine tarball, rather than updating the .cabal file with the latest revision from the package archive.]' \
256 296 '*:package:_cabal_list_packages'
@@ -285,8 +325,8 @@ _cabal_haddock ()
285 325 _cabal_help ()
286 326 {
287 327 local -a cmds
288   - cmds=(install update list info fetch get check sdist upload report run init
289   - configure build repl sandbox copy haddock clean hscolour register test bench help)
  328 + cmds=(install update list info fetch freeze get check sdist upload report run init
  329 + configure build repl sandbox haddock exec copy clean hscolour register test bench help)
290 330 _arguments \
291 331 {-h,--help}'[Show help]' \
292 332 '*::command:( $cmds )'
@@ -307,10 +347,22 @@ _cabal_hscolour ()
307 347
308 348 _cabal_info ()
309 349 {
  350 + local context state state_descr line
  351 + typeset -A opt_args
  352 +
310 353 _arguments \
311 354 {-h,--help}'[show help]' \
312 355 {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \
  356 + '--package-db=[use a given package database]:: :->default-db-or-filepath' \
313 357 '*:package:_cabal_list_packages'
  358 +
  359 + case $state in
  360 + (default-db-or-filepath)
  361 + _alternative \
  362 + ':default db:(global user clear)' \
  363 + ':filepath:_files'
  364 + ;;
  365 + esac
314 366 }
315 367
316 368 _cabal_install ()
@@ -328,6 +380,7 @@ _cabal_install ()
328 380 '--lhc[compile with LHC]' \
329 381 '--hugs[compile with Hugs]' \
330 382 '--uhc[compile with UHC]' \
  383 + '--haskell-suite[compile with a haskell-suite compiler]' \
331 384 {-w,--with-compiler=}'[give the path to a particular compiler]:file:_files' \
332 385 '--with-hc-pkg=[give the path to the package tool]:file:_files' \
333 386 '--prefix=[take this prefix in preparation of installation]:directory:_files -/' \
@@ -348,10 +401,10 @@ _cabal_install ()
348 401 '--disable-library-vanilla[disable Vanilla libraries]' \
349 402 {-p,--enable-library-profiling}'[enable Library profiling]' \
350 403 '--disable-library-profiling[disable Library profiling]' \
351   - '--enable-executable-dynamic[enable Executable dynamic linking]' \
352   - '--disable-executable-dynamic[disable Executable dynamic linking]' \
353 404 '--enable-shared[enable Shared library]' \
354 405 '--disable-shared[disable Shared library]' \
  406 + '--enable-executable-dynamic[enable Executable dynamic linking]' \
  407 + '--disable-executable-dynamic[disable Executable dynamic linking]' \
355 408 '--enable-executable-profiling[enable Executable profiling]' \
356 409 '--disable-executable-profiling[disable Executable profiling]' \
357 410 {-O-,--enable-optimization=}'[build with optimization]:level:(0 1 2)' \
@@ -365,7 +418,7 @@ _cabal_install ()
365 418 '--configure-option=[extra option for configure]' \
366 419 '--user[enable doing a per-user installation]' \
367 420 '--global[disable doing a per-user installation]' \
368   - '--package-db=[use a specific package database]:files:_files' \
  421 + '--package-db=[use a given package database]:: :->default-db-or-filepath' \
369 422 {-f,--flags=}'[force values for the given flags]:flags:' \
370 423 '--extra-include-dirs=[a list of directories to search for header files]:directory:_files -/' \
371 424 '--extra-lib-dirs=[a list of directories to search for external libraries]:directory:_files -/' \
@@ -381,6 +434,7 @@ _cabal_install ()
381 434 '--constraint=[a list of additional constraints on the dependencies]' \
382 435 '--preference=[specify preferences on the version of a package]' \
383 436 '--solver=[select dependency solver to use]:solver:(topdown modular choose)' \
  437 + '--allow-newer=[ignore upper bounds in dependencies on some or all packages]' \
384 438 '--enable-documentation[enable building of documentation]' \
385 439 '--disable-documentation[disable building of documentation]' \
386 440 '--doc-index-file=[a central index of haddock API documentation]:file:_files' \
@@ -399,11 +453,15 @@ _cabal_install ()
399 453 '--build-log=[log all builds to file]:file:_files' \
400 454 '--remote-build-reporting=[generate build reports to send to a remote]:level:(none anonymous detailed)' \
401 455 '--one-shot[do not record the packages in the world file]' \
  456 + '--run-tests[run package test suites during installation]' \
402 457 {-j,--jobs=}'[run NUM jobs simultaneously]' \
403 458 '--haddock-hoogle[generate a hoogle database]' \
404 459 '--haddock-html[generate HTML documentation]' \
405 460 '--haddock-html-location=[location of HTML documentation]:url:' \
406 461 '--haddock-executables[run haddock for Executables targets]' \
  462 + '--haddock-tests[run haddock for Test Suite targets]' \
  463 + '--haddock-benchmarks[run haddock for Benchmarks targets]' \
  464 + '--haddock-all[run haddock for all targets]' \
407 465 '--haddock-internal[run haddock for internal modules]' \
408 466 '--haddock-css=[path to the haddock stylesheet]:file:_files' \
409 467 '--haddock-hyperlink-source[hyperlink the documentation to the source code]' \
@@ -412,6 +470,11 @@ _cabal_install ()
412 470 '*:: :->package-or-cabal-file'
413 471
414 472 case $state in
  473 + (default-db-or-filepath)
  474 + _alternative \
  475 + ':default db:(global user clear)' \
  476 + ':filepath:_files'
  477 + ;;
415 478 (package-or-cabal-file)
416 479 _alternative \
417 480 ':package:_cabal_list_packages' \
@@ -422,12 +485,24 @@ _cabal_install ()
422 485
423 486 _cabal_list ()
424 487 {
  488 + local context state state_descr line
  489 + typeset -A opt_args
  490 +
425 491 _arguments \
426 492 {-h,--help}'[show help]' \
427 493 {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \
428 494 '--installed[only print installed packages]' \
429 495 '--simple-output[print in a easy-to-parse format]' \
  496 + '--package-db=[use a given package database]:: :->default-db-or-filepath' \
430 497 '*:package:_cabal_list_packages'
  498 +
  499 + case $state in
  500 + (default-db-or-filepath)
  501 + _alternative \
  502 + ':default db:(global user clear)' \
  503 + ':filepath:_files'
  504 + ;;
  505 + esac
431 506 }
432 507
433 508 _cabal_register ()
@@ -467,8 +542,8 @@ _cabal_run ()
467 542 {-h,--help}'[show help]' \
468 543 {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \
469 544 '--builddir=[the directory where Cabal puts generated build files]:directory:_files -/' \
470   - $_cabal_programs \
471 545 {-j,--jobs=}'[run NUM jobs simultaneously]' \
  546 + $_cabal_programs \
472 547 "--only[don't reinstall add-source dependencies (sandbox-only)]"
473 548 }
474 549
@@ -532,6 +607,7 @@ _cabal_test ()
532 607 '--test-options=[give extra options to test executables]' \
533 608 '--test-option=[give an extra option to test executables]' \
534 609 {-j,--jobs=}'[run NUM jobs simultaneously]' \
  610 + $_cabal_programs \
535 611 "--only[don't reinstall add-source dependencies (sandbox-only)]"
536 612 }
537 613
@@ -548,8 +624,8 @@ _cabal_upload ()
548 624 {-h,--help}'[show help]' \
549 625 {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \
550 626 {-c,--check}'[do not upload, just do QA checks]' \
551   - {-u,--username=}'[hackage username]' \
552   - {-p,--password=}'[hackage password]' \
  627 + {-u-,--username=}'[hackage username]' \
  628 + {-p-,--password=}'[hackage password]' \
553 629 '*:file:_files -g "*.tar.gz"'
554 630 }
555 631

0 comments on commit 059df4e

Please sign in to comment.
Something went wrong with that request. Please try again.