@@ -106,124 +106,28 @@ _autotest_complete() {
106
106
_complete_board_sysroot_flag && return 0
107
107
}
108
108
109
- # Complete cros_workon 's <command> argument.
109
+ # Complete flatcar_workon 's <command> argument.
110
110
#
111
111
# TODO(petkov): We should probably extract the list of commands from
112
- # cros_workon --help, just like we do for flags (see _flag_complete).
112
+ # flatcar_workon --help, just like we do for flags (see _flag_complete).
113
113
#
114
114
# TODO(petkov): Currently, this assumes that the command is the first
115
115
# argument. In practice, the command is the first non-flag
116
116
# argument. I.e., this should be fixed to support something like
117
- # "cros_workon --all list".
118
- _complete_cros_workon_command () {
117
+ # "flatcar_workon --all list".
118
+ _complete_flatcar_workon_command () {
119
119
[ ${COMP_CWORD} -eq 1 ] || return 1
120
120
local command="${COMP_WORDS[1]}"
121
- COMPREPLY=($(compgen -W "start stop list iterate " -- "$command"))
121
+ COMPREPLY=($(compgen -W "start stop list" -- "$command"))
122
122
return 0
123
123
}
124
124
125
- # Prints the full path to the cros_workon executable, handling tilde
126
- # expansion for the current user.
127
- _cros_workon_executable() {
128
- local cros_workon="${COMP_WORDS[0]}"
129
- if [[ "$cros_workon" == '~/'* ]]; then
130
- cros_workon="$HOME/${cros_workon#'~/'}"
131
- fi
132
- echo "$cros_workon"
133
- }
134
-
135
- # Lists the workon (or live, if --all is passed in) ebuilds. Lists
136
- # both the full names (e.g., chromeos-base/metrics) as well as just
137
- # the ebuild names (e.g., metrics).
138
- _cros_workon_list() {
139
- local cros_workon=$(_cros_workon_executable)
140
- ${cros_workon} list $1 | sed 's,\(.\+\)/\(.\+\),\1/\2 \2,'
141
- }
142
-
143
- # Completes the current cros_workon argument assuming it's a
144
- # package/ebuild name.
145
- _complete_cros_workon_package() {
146
- [ ${COMP_CWORD} -gt 1 ] || return 1
147
- local package="${COMP_WORDS[COMP_CWORD]}"
148
- local command="${COMP_WORDS[1]}"
149
- # If "start", complete based on all workon packages.
150
- if [[ ${command} == "start" ]]; then
151
- COMPREPLY=($(compgen -W "$(_cros_workon_list --all)" -- "$package"))
152
- return 0
153
- fi
154
- # If "stop" or "iterate", complete based on all live packages.
155
- if [[ ${command} == "stop" ]] || [[ ${command} == "iterate" ]]; then
156
- COMPREPLY=($(compgen -W "$(_cros_workon_list)" -- "$package"))
157
- return 0
158
- fi
159
- return 1
160
- }
161
-
162
- # Complete cros_workon arguments.
163
- _cros_workon() {
125
+ # Complete flatcar_workon arguments.
126
+ _flatcar_workon() {
164
127
COMPREPLY=()
165
128
_flag_complete && return 0
166
129
_complete_board_sysroot_flag && return 0
167
- _complete_cros_workon_command && return 0
168
- _complete_cros_workon_package && return 0
169
- return 0
170
- }
171
-
172
- _list_repo_commands() {
173
- local repo=${COMP_WORDS[0]}
174
- "$repo" help --all | grep -E '^ ' | sed 's/ \([^ ]\+\) .\+/\1/'
175
- }
176
-
177
- _list_repo_branches() {
178
- local repo=${COMP_WORDS[0]}
179
- "$repo" branches 2>&1 | grep \| | sed 's/[ *][Pp ] *\([^ ]\+\) .*/\1/'
180
- }
181
-
182
- _list_repo_projects() {
183
- local repo=${COMP_WORDS[0]}
184
- "$repo" manifest -o /dev/stdout 2> /dev/null \
185
- | grep 'project name=' \
186
- | sed 's/.\+name="\([^"]\+\)".\+/\1/'
187
- }
188
-
189
- # Complete repo's <command> argument.
190
- _complete_repo_command() {
191
- [ ${COMP_CWORD} -eq 1 ] || return 1
192
- local command=${COMP_WORDS[1]}
193
- COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "$command"))
194
- return 0
195
- }
196
-
197
- _complete_repo_arg() {
198
- [ ${COMP_CWORD} -gt 1 ] || return 1
199
- local command=${COMP_WORDS[1]}
200
- local current=${COMP_WORDS[COMP_CWORD]}
201
- if [[ ${command} == "abandon" ]]; then
202
- if [[ ${COMP_CWORD} -eq 2 ]]; then
203
- COMPREPLY=($(compgen -W "$(_list_repo_branches)" -- "$current"))
204
- else
205
- COMPREPLY=($(compgen -W "$(_list_repo_projects)" -- "$current"))
206
- fi
207
- return 0
208
- fi
209
- if [[ ${command} == "help" ]]; then
210
- [ ${COMP_CWORD} -eq 2 ] && \
211
- COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "$current"))
212
- return 0
213
- fi
214
- if [[ ${command} == "start" ]]; then
215
- [ ${COMP_CWORD} -gt 2 ] && \
216
- COMPREPLY=($(compgen -W "$(_list_repo_projects)" -- "$current"))
217
- return 0
218
- fi
219
- return 1
220
- }
221
-
222
- # Complete repo arguments.
223
- _complete_repo() {
224
- COMPREPLY=()
225
- _complete_repo_command && return 0
226
- _complete_repo_arg && return 0
130
+ _complete_flatcar_workon_command && return 0
227
131
return 0
228
132
}
229
133
@@ -234,8 +138,7 @@ complete -o bashdefault -o default -F _board_sysroot \
234
138
image_to_usb.sh \
235
139
mod_image_for_test.sh
236
140
complete -o bashdefault -o default -o nospace -F _autotest_complete autotest
237
- complete -F _cros_workon cros_workon
238
- complete -F _complete_repo repo
141
+ complete -F _flatcar_workon flatcar_workon
239
142
240
143
### Local Variables:
241
144
### mode: shell-script
0 commit comments