Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

cordova.completion 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. # KIND, either express or implied. See the License for the
  16. # specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. platforms() {
  20. get_cordova && COMPREPLY=( $(compgen -W "$(${CORDOVA_BIN} platform ls | tr -d "[]',")" -- $1) )
  21. }
  22. plugins() {
  23. get_cordova && COMPREPLY=( $(compgen -W "$(${CORDOVA_BIN} plugin ls | tr -d "[]',")" -- $1) )
  24. }
  25. get_cordova() {
  26. local cordova
  27. if [[ -n "${CORDOVA_BIN}" ]]; then return 0; fi
  28. cordova=$(eval echo ${COMP_WORDS[0]})
  29. if [[ -x $cordova ]]; then CORDOVA_BIN=$cordova; return 0; fi
  30. cordova=$(which cordova)
  31. if [[ $? -eq 0 ]]; then CORDOVA_BIN=$cordova; return 0; fi
  32. return 1
  33. }
  34. get_top_level_dir() {
  35. local path
  36. path=$(pwd)
  37. while [ $path != '/' ]; do
  38. if [ -d $path/.cordova ]; then
  39. echo $path
  40. return 0
  41. fi
  42. path=$(dirname $path)
  43. done
  44. return 1
  45. }
  46. _cordova()
  47. {
  48. local cur prev opts
  49. COMPREPLY=()
  50. cur="${COMP_WORDS[COMP_CWORD]}"
  51. # Skip over any initial command line switches
  52. local i=1
  53. while [[ $i -lt ${#COMP_WORDS[*]} ]] && [[ "${COMP_WORDS[${i}]}" == -* ]]; do
  54. i=$((i+1));
  55. done
  56. # For the first word, supply all of the valid top-level commands
  57. if [[ ${COMP_CWORD} -eq $i ]]; then
  58. opts="create platform plugin prepare compile build emulate serve"
  59. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  60. return 0
  61. fi
  62. case "${COMP_WORDS[$i]}" in
  63. create)
  64. if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
  65. COMPREPLY=( $(compgen -d -- ${cur}) )
  66. return 0
  67. fi
  68. ;;
  69. platform)
  70. if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
  71. opts="add rm remove ls"
  72. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  73. return 0
  74. fi
  75. case "${COMP_WORDS[$((i+1))]}" in
  76. add)
  77. opts="ios android wp7 wp8 blackberry www"
  78. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  79. return 0;
  80. ;;
  81. rm|remove)
  82. platforms ${cur}
  83. return 0
  84. ;;
  85. esac
  86. ;;
  87. plugin)
  88. if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
  89. opts="add rm remove ls"
  90. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  91. return 0
  92. fi
  93. case "${COMP_WORDS[$((i+1))]}" in
  94. add)
  95. COMPREPLY=( $(compgen nospace -d -- ${cur}) )
  96. return 0;
  97. ;;
  98. rm|remove)
  99. plugins ${cur}
  100. return 0
  101. ;;
  102. esac
  103. ;;
  104. prepare|compile|build|emulate)
  105. platforms ${cur}
  106. return 0
  107. ;;
  108. serve)
  109. if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
  110. platforms ${cur}
  111. return 0
  112. fi
  113. ;;
  114. esac
  115. }
  116. complete -F _cordova cordova