Skip to content

Commit

Permalink
Update Zsh completions and allow completion on ports tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Jehops committed Feb 9, 2019
1 parent b2b6178 commit a196398
Showing 1 changed file with 50 additions and 17 deletions.
67 changes: 50 additions & 17 deletions completions/zsh/_poudriere
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,39 @@ _poudriere_pt() {
_values "poudriere portstrees" ${${(f)"$(${service} ports -lq)"}%% *}
}

_poudriere_direct_port() {
# Find a ports tree to complete ports
local prev_word=
local ports_tree=
local w

# Determine whether a tree has already been specified with -p
for w in ${words[@]}; do
if [[ $w == -p ]]; then
prev_word=-p
elif [[ $prev_word == -p ]]; then
ports_tree="$w"
break
fi
done

# Determine whether the default tree is present
if [[ -z $ports_tree ]] && poudriere ports -l | grep -q '^default '; then
ports_tree=default
elif [[ -z $ports_tree ]]; then
return
fi

local ports_tree_path="$(poudriere ports -lq | awk -v tree=$ports_tree '{if (match($1, tree)) {print $5}}')"

# complete port
_path_files -W ${ports_tree_path} -/
}

_bulk=(
'-a[build the whole ports tree]'
'-f[get the list of ports to build from a file]:name of file:_files'
'-B[what buildname to use]:buildname'
'(-f *)-a[build the whole ports tree]'
'(-a *)-f+[get the list of ports to build from a file]:name of file:_files'
'-B+[what buildname to use]:buildname'
'-c[clean all the previously built binary packages and logs]'
'-C[clean only the packages listed on the command line or -f file]'
'-i[interactive mode. enter jail for interactive testing and automatically cleanup when done]'
Expand All @@ -25,12 +54,13 @@ _bulk=(
'-F[only fetch from original master_site (skip FreeBSD mirrors)]'
'-S[don\x27t recursively rebuild packages affected by other packages requiring incremental rebuild]'
'-J[run n jobs in parallel, and optionally run a different number of jobs in parallel while preparing the build]::'
'-j[run only on the given jail]::jail name:_poudriere_jail'
'-j+[run only on the given jail]:jail name:_poudriere_jail'
'-N[do not build package repository or INDEX when build completed]'
'-p[specify on which ports tree the bulk build will be done]::tree:_poudriere_pt'
'-p+[specify on which ports tree the bulk build will be done]:tree:_poudriere_pt'
'-v[be verbose; show more information. Use twice to enable debug output]'
'-w[save WRKDIR on failed builds]'
'-z[specify which SET to use]::'
'-z+[specify which SET to use]:'
'(-a -f)*:cat/port:_poudriere_direct_port'
)

_daemon=(
Expand Down Expand Up @@ -107,16 +137,17 @@ _logclean=(
)

_options=(
'-a[indicates the TARGET_ARCH if no jail is specified]::arch:(amd64 i386)'
'-a+[indicates the TARGET_ARCH if no jail is specified]::arch:(amd64 i386)'
"(-C)-c[use 'make config' target]::"
"(-c)-C[use 'make config-conditional' target]::"
'-f[give the list of ports to set options]:name of file:_files'
'-j[run on the given jail]::name:_poudriere_jail'
'(*)-f+[give the list of ports to set options]:name of file:_files'
'-j+[run on the given jail]:name:_poudriere_jail'
'-n[do not configure/show/remove options of dependencies]::'
'-p[specify on which ports tree the configuration will be done]::tree:_poudriere_pt'
'-p+[specify on which ports tree the configuration will be done]::tree:_poudriere_pt'
'(-r)-s[show options instead of configuring them]::'
'(-s)-r[show port options instead of configuring them]::'
'-z[Specify which SET to use]::'
'-z+[Specify which SET to use]:'
'(-f)*:cat/port:_poudriere_direct_port'
)

_pkgclean=(
Expand Down Expand Up @@ -167,21 +198,23 @@ _status=(
)

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

_poudriere () {
Expand Down

0 comments on commit a196398

Please sign in to comment.