Skip to content

Commit a196398

Browse files
committed
Update Zsh completions and allow completion on ports tree
1 parent b2b6178 commit a196398

File tree

1 file changed

+50
-17
lines changed

1 file changed

+50
-17
lines changed

completions/zsh/_poudriere

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,39 @@ _poudriere_pt() {
88
_values "poudriere portstrees" ${${(f)"$(${service} ports -lq)"}%% *}
99
}
1010

11+
_poudriere_direct_port() {
12+
# Find a ports tree to complete ports
13+
local prev_word=
14+
local ports_tree=
15+
local w
16+
17+
# Determine whether a tree has already been specified with -p
18+
for w in ${words[@]}; do
19+
if [[ $w == -p ]]; then
20+
prev_word=-p
21+
elif [[ $prev_word == -p ]]; then
22+
ports_tree="$w"
23+
break
24+
fi
25+
done
26+
27+
# Determine whether the default tree is present
28+
if [[ -z $ports_tree ]] && poudriere ports -l | grep -q '^default '; then
29+
ports_tree=default
30+
elif [[ -z $ports_tree ]]; then
31+
return
32+
fi
33+
34+
local ports_tree_path="$(poudriere ports -lq | awk -v tree=$ports_tree '{if (match($1, tree)) {print $5}}')"
35+
36+
# complete port
37+
_path_files -W ${ports_tree_path} -/
38+
}
39+
1140
_bulk=(
12-
'-a[build the whole ports tree]'
13-
'-f[get the list of ports to build from a file]:name of file:_files'
14-
'-B[what buildname to use]:buildname'
41+
'(-f *)-a[build the whole ports tree]'
42+
'(-a *)-f+[get the list of ports to build from a file]:name of file:_files'
43+
'-B+[what buildname to use]:buildname'
1544
'-c[clean all the previously built binary packages and logs]'
1645
'-C[clean only the packages listed on the command line or -f file]'
1746
'-i[interactive mode. enter jail for interactive testing and automatically cleanup when done]'
@@ -25,12 +54,13 @@ _bulk=(
2554
'-F[only fetch from original master_site (skip FreeBSD mirrors)]'
2655
'-S[don\x27t recursively rebuild packages affected by other packages requiring incremental rebuild]'
2756
'-J[run n jobs in parallel, and optionally run a different number of jobs in parallel while preparing the build]::'
28-
'-j[run only on the given jail]::jail name:_poudriere_jail'
57+
'-j+[run only on the given jail]:jail name:_poudriere_jail'
2958
'-N[do not build package repository or INDEX when build completed]'
30-
'-p[specify on which ports tree the bulk build will be done]::tree:_poudriere_pt'
59+
'-p+[specify on which ports tree the bulk build will be done]:tree:_poudriere_pt'
3160
'-v[be verbose; show more information. Use twice to enable debug output]'
3261
'-w[save WRKDIR on failed builds]'
33-
'-z[specify which SET to use]::'
62+
'-z+[specify which SET to use]:'
63+
'(-a -f)*:cat/port:_poudriere_direct_port'
3464
)
3565

3666
_daemon=(
@@ -107,16 +137,17 @@ _logclean=(
107137
)
108138

109139
_options=(
110-
'-a[indicates the TARGET_ARCH if no jail is specified]::arch:(amd64 i386)'
140+
'-a+[indicates the TARGET_ARCH if no jail is specified]::arch:(amd64 i386)'
111141
"(-C)-c[use 'make config' target]::"
112142
"(-c)-C[use 'make config-conditional' target]::"
113-
'-f[give the list of ports to set options]:name of file:_files'
114-
'-j[run on the given jail]::name:_poudriere_jail'
143+
'(*)-f+[give the list of ports to set options]:name of file:_files'
144+
'-j+[run on the given jail]:name:_poudriere_jail'
115145
'-n[do not configure/show/remove options of dependencies]::'
116-
'-p[specify on which ports tree the configuration will be done]::tree:_poudriere_pt'
146+
'-p+[specify on which ports tree the configuration will be done]::tree:_poudriere_pt'
117147
'(-r)-s[show options instead of configuring them]::'
118148
'(-s)-r[show port options instead of configuring them]::'
119-
'-z[Specify which SET to use]::'
149+
'-z+[Specify which SET to use]:'
150+
'(-f)*:cat/port:_poudriere_direct_port'
120151
)
121152

122153
_pkgclean=(
@@ -167,21 +198,23 @@ _status=(
167198
)
168199

169200
_testport=(
170-
'-j[run inside the given jail]::name:_poudriere_jail'
171-
'-B[What buildname to use]::'
201+
'-j+[run inside the given jail]:name:_poudriere_jail'
202+
'-o+[Specify an origin in the portstree]:origin:_poudriere_direct_port'
203+
'-B+[What buildname to use]:'
172204
'-c[run make config for the given port]::'
173205
'-i[interactive mode]'
174206
'-I[advanced interactive mode]'
175-
'-J[Run n jobs in parallel for dependencies, and optionally run a different number of jobs in parallel while preparing the build]::'
207+
'-J[Run n jobs in parallel for dependencies, and optionally run a different number of jobs in parallel while preparing the build]:'
176208
"-k[don't consider failures as fatal; find all failures]"
177209
'-n[show what will be done, but do not build any packages]'
178210
'-N[do not build package repository when build of dependencies completed]'
179-
'-p[specifies which ports tree to use]::tree:_poudriere_pt'
180-
'-P[use custom prefix]'
181211
"-S[don't recursively rebuild packages affected by other packages requiring incremental rebuild]"
212+
'-p+[specifies which ports tree to use]::tree:_poudriere_pt'
213+
'-P[use custom prefix]'
182214
'-v[be verbose; show more information]'
183215
'-w[save WRKDIR on failed builds]'
184-
'-z[specify which SET to use]::'
216+
'-z+[specify which SET to use]::'
217+
'*:cat/port:_poudriere_direct_port'
185218
)
186219

187220
_poudriere () {

0 commit comments

Comments
 (0)