forked from sergioprado/bitbake-bash-completion
-
Notifications
You must be signed in to change notification settings - Fork 3
/
bitbake_layers_completion
188 lines (167 loc) · 6.24 KB
/
bitbake_layers_completion
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!bash
# Bash completion support for bitbake-layers tool,
# compatible with Bitbake 1.40.0.
#
# Copyright (C) 2018 Lukasz Gardon <lukasz.gardon@gmail.com>
#
# Distributed under the MIT License (MIT)
#
_bitbake_layers()
{
local cur prev opts_short opts_long subcommands colors
local opts_long_add_layer opts_short_add_layer opts_long_show_overlayed
local opts_short_show_overlayed opts_long_show_recipes opts_short_show_recipes
local opts_long_show_cross_depends opts_short_show_cross_depends
local opts_long_show_layerindex_fetch opts_short_show_layerindex_fetch
local opts_long_show_layerindex_show_depends opts_short_show_layerindex_show_depends
local opts_long_show_create_layer opts_short_show_create_layer bb_class_files classes
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts_short="-d -q -F -h"
opts_long="--debug --quiet --force --color --help"
subcommands="layerindex-fetch layerindex-show-depends add-layer \
remove-layer flatten show-layers show-overlayed \
show-recipes show-appends show-cross-depends \
create-layer"
colors="auto always never"
opts_long_show_overlayed="--help --filenames --same-version"
opts_short_show_overlayed="-h -f -s"
opts_long_show_recipes="--help --filenames --multiple --inherits"
opts_short_show_recipes="-h -f -m -i"
opts_long_show_layerindex_fetch="--help --show-only --branch --ignore"
opts_short_show_layerindex_fetch="-h -n -b -i"
opts_long_add_layer="--help --priority --example-recipe-name --example-recipe-version"
opts_short_add_layer="-h"
opts_long_show_cross_depends="--help --filenames --ignore"
opts_short_show_cross_depends="-h -f -i"
opts_long_show_layerindex_show_depends="--help --branch"
opts_short_show_layerindex_show_depends="-h -b"
opts_long_show_create_layer="--help --priority --example-recipe-name --example-recipe-version"
opts_short_show_create_layer="-h -p -e -v"
bb_class_files=".bb_class_files"
_get_classes() {
find $BBPATH/../meta*/classes/ -name *.bbclass -exec basename {} \; | sed 's/.bbclass//' > $bb_class_files
}
if [[ "${COMP_WORDS[@]}" =~ show-recipes ]] ; then
if [[ "$prev" == "--inherits" ]] || [[ "$prev" == "-i" ]]; then
_get_classes
classes=$(cat $bb_class_files)
COMPREPLY=( $(compgen -W "${classes}" -- ${cur}) )
return 0
fi
fi
if [[ "${COMP_WORDS[1]}" =~ show-layers|show-appends|remove-layer|flatten ]]; then
case "$cur" in
"--"*)
COMPREPLY=( $(compgen -W "--help" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "-h" -- ${cur}) )
return 0
;;
esac
elif [[ "${COMP_WORDS[1]}" == "add-layer" ]]; then
case "$cur" in
"--"*|"")
COMPREPLY=( $(compgen -W "${opts_long_add_layer}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short_add_layer}" -- ${cur}) )
return 0
;;
esac
elif [[ "${COMP_WORDS[1]}" == "show-overlayed" ]]; then
case "$cur" in
"--"*|"")
COMPREPLY=( $(compgen -W "${opts_long_show_overlayed}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short_show_overlayed}" -- ${cur}) )
return 0
;;
esac
elif [[ "${COMP_WORDS[1]}" == "show-recipes" ]]; then
case "$cur" in
"--"*|"")
COMPREPLY=( $(compgen -W "${opts_long_show_recipes}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short_show_recipes}" -- ${cur}) )
return 0
;;
esac
elif [[ "${COMP_WORDS[1]}" == "show-cross-depends" ]]; then
case "$cur" in
"--"*|"")
COMPREPLY=( $(compgen -W "${opts_long_show_cross_depends}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short_show_cross_depends}" -- ${cur}) )
return 0
;;
esac
elif [[ "${COMP_WORDS[1]}" == "layerindex-fetch" ]]; then
case "$cur" in
"--"*|"")
COMPREPLY=( $(compgen -W "${opts_long_show_layerindex_fetch}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short_show_layerindex_fetch}" -- ${cur}) )
return 0
;;
esac
elif [[ "${COMP_WORDS[1]}" == "layerindex-show-depends" ]]; then
case "$cur" in
"--"*|"")
COMPREPLY=( $(compgen -W "${opts_long_show_layerindex_show_depends}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short_show_layerindex_show_depends}" -- ${cur}) )
return 0
;;
esac
elif [[ "${COMP_WORDS[1]}" == "create-layer" ]]; then
case "$cur" in
"--"*|"")
COMPREPLY=( $(compgen -W "${opts_long_show_create_layer}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short_show_create_layer}" -- ${cur}) )
return 0
;;
esac
fi
case "$prev" in
"-c"|"--color")
COMPREPLY=( $(compgen -W "${colors}" -- ${cur}) )
return 0
;;
esac
case "$cur" in
"--"*)
COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
return 0
;;
esac
if [[ ${prev} == "bitbake-layers" ]]; then
COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) )
return 0
elif [[ ! ${subcommands} =~ [[:space:]]${cur}[[:space:]] ]]; then
COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) )
return 0
fi
}
complete -F _bitbake_layers bitbake-layers