-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautocomplete
More file actions
executable file
·91 lines (57 loc) · 3.16 KB
/
autocomplete
File metadata and controls
executable file
·91 lines (57 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
_ogautocomplete()
{
local currentArg previousArg ogArgs dockerArgs dockerProjectArgs appInstallArgs gitArgs gitSubArgs
COMPREPLY=()
currentArg="${COMP_WORDS[COMP_CWORD]}"
previousArg="${COMP_WORDS[COMP_CWORD-1]}"
ogArgs="docker update regen-hosts help"
dockerArgs="boot init destroy clone build help"
dockerProjects=""
dockerProjectArgs="install info git"
appInstallArgs="drupal django ckan"
gitArgs="fetch pull exec"
gitSubArgs="opengov og gcweb_bootstrap oc_search oc_searches solrclient ckan ckanapi ckanext-az-keyvault ckanext-canada ckanext-citeproc ckanext-cloudstorage ckanext-dcat ckanext-dsaudit ckanext-excelforms ckanext-fluent ckanext-gcnotify ckanext-openapiview ckanext-power-bi ckanext-recombinant ckanext-scheming ckanext-security ckanext-validation ckanext-xloader frictionless-py"
if [[ -d "${HOME}/.docker-og.d" ]]; then
if [[ ! "$(find ${HOME}/.docker-og.d -empty)" ]]; then
for FILE in ${HOME}/.docker-og.d/*; do
fileName="$(basename -- "$FILE")"
dockerArgs="$dockerArgs ${fileName%.*}"
dockerProjects="$dockerProjects ${fileName%.*}"
done
fi
fi
if [[ "$previousArg" == "og" ]]; then # show `og` hints
COMPREPLY=( $(compgen -W "${ogArgs}" ${currentArg}) )
return 0
elif [[ "$previousArg" == "docker" ]]; then # show `og docker` hints
COMPREPLY=( $(compgen -W "${dockerArgs}" ${currentArg}) )
return 0
elif [[ "$previousArg" == "clone" || "$previousArg" == "destroy" ]]; then # show `og docker clone` and `og docker destroy` hints
COMPREPLY=( $(compgen -W "${dockerProjects}" ${currentArg}) )
return 0
elif [[ "${COMP_WORDS[COMP_CWORD-2]}" == "clone" && "$dockerProjects" == *"${previousArg}"* ]]; then # show `og docker clone [PROJECT ID]` hints
COMPREPLY=( $(compgen -W "${dockerProjects}" ${currentArg}) )
return 0
elif [[ "${COMP_WORDS[COMP_CWORD-3]}" == "clone" && "$dockerProjects" == *"${previousArg}"* ]]; then # stop `og docker clone` hints after two PROJECT IDs
return 0
elif [[ "$previousArg" == "git" ]]; then # show `og docker [PROJECT ID] git` hints
COMPREPLY=( $(compgen -W "${gitArgs}" ${currentArg}) )
return 0
elif [[ "$previousArg" == "fetch" || "$previousArg" == "pull" ]]; then # show `og docker [PROJECT ID] git fetch|pull` hints
COMPREPLY=( $(compgen -W "all ${gitSubArgs}" ${currentArg}) )
return 0
elif [[ "$previousArg" == "exec" ]]; then # show `og docker [PROJECT ID] git exec` hints
COMPREPLY=( $(compgen -W "${gitSubArgs}" ${currentArg}) )
return 0
elif [[ "$dockerProjects" == *"${previousArg}"* ]]; then # show `og docker [PROJECT ID]` hints
COMPREPLY=( $(compgen -W "${dockerProjectArgs}" ${currentArg}) )
return 0
elif [[ "$previousArg" == "install" ]]; then # show `og docker [PROJECT ID] install` hints
COMPREPLY=( $(compgen -W "${appInstallArgs}" ${currentArg}) )
return 0
else # return no error otherwise
return 0
fi
}
complete -o nosort -o nospace -F _ogautocomplete og