Integrate longitudinal high-dimensional data in a data warehouse using the git commit graph to store temporal information and git annex to store large data in a content-addressable fashion.
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.

85 lines
2.8KB

  1. #!/bin/bash
  2. function _completions
  3. {
  4. #1 : command
  5. #2 : current word
  6. #3 : previous word
  7. #COMP_WORDS = array of words typed after the name of the program
  8. #COMP_CWORD = index pointing to the word the cursor is at
  9. #COMP_LINE = the current command line
  10. local cur prev words cword
  11. # _get_comp_words_by_ref -n : cur
  12. _init_completion -n :
  13. local IFS=$' \t\n'
  14. local OPTIONS
  15. local PATIENT
  16. if [[ "$cword" -eq 1 ]];then
  17. OPTIONS="add list get"
  18. elif [[ "$cword" -eq 2 ]];then
  19. local VERB="${words[1]}"
  20. case $VERB in
  21. list) OPTIONS="all " ;&
  22. add) OPTIONS+="patient sample data result diagnosis" ;;
  23. get) OPTIONS="prov graph timeline last sparql log file object" ;;
  24. esac
  25. elif [[ "$cword" -gt 2 ]];then
  26. local VERB="${words[1]}"
  27. local OBJECT="${words[2]}"
  28. if [[ "$COMP_LINE" =~ (-p|--patient)[[:space:]]+([^ ]*) ]];then
  29. PATIENT="${BASH_REMATCH[2]}"
  30. fi
  31. case $VERB in
  32. add)
  33. case $OBJECT in
  34. diagnosis|result) OPTIONS+="--use " ;&
  35. data) OPTIONS+="--revision_of --invalidate " ;&
  36. sample) OPTIONS+="--patient " ;&
  37. patient) OPTIONS+="--id --method --provider --date --message ";;
  38. esac
  39. if [[ $OBJECT == "data" || $OBJECT == "result" ]];then
  40. OPTIONS+="--sample $(ls)"
  41. fi
  42. ;;
  43. list)
  44. if [[ $OBJECT != "patient" ]];then
  45. if [[ "$PATIENT" ]];then
  46. OPTIONS="$(git ommix list all --patient $PATIENT)"
  47. else
  48. OPTIONS="--patient "
  49. fi
  50. fi
  51. ;;
  52. get)
  53. if [[ "$PATIENT" ]];then
  54. OPTIONS="$(git ommix list all --patient $PATIENT) "
  55. else
  56. OPTIONS="--patient "
  57. fi
  58. ;;
  59. esac
  60. case "$prev" in
  61. -p|--patient) OPTIONS="$(git ommix list patient)" ;;
  62. -s|--sample) OPTIONS="$(git ommix list sample --patient $PATIENT)" ;;
  63. --use) if [[ "$OBJECT" == "result" ]];then
  64. OPTIONS="$(git ommix list data --patient $PATIENT)"
  65. elif [[ "$OBJECT" == "diagnosis" ]];then
  66. OPTIONS="$(git ommix list result --patient $PATIENT)
  67. $(git ommix list diagnosis --patient $PATIENT)"
  68. fi ;;
  69. --invalidate|--revision_of) OPTIONS="$(git ommix list $OBJECT --patient $PATIENT)" ;;
  70. esac
  71. fi
  72. COMPREPLY=($(compgen -W "$OPTIONS" -- "$cur"))
  73. __ltrim_colon_completions "$cur"
  74. }
  75. complete -F _completions git-ommix