-
Notifications
You must be signed in to change notification settings - Fork 391
refactor: adjust to util/xfunc primary command convention #965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
56a7cec
0f927c0
185b063
d55f5e6
8a0a71e
d569ea2
473278f
5c1d270
898926c
01611dd
5085d6b
d9bf3f8
c14986a
0d27563
80da3de
a4294f3
643886c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,11 @@ | |
|
||
# @since 2.12 | ||
_comp_xfunc_rpm_installed_packages() | ||
{ | ||
_comp_cmd_rpm__installed_packages rpm | ||
} | ||
|
||
_comp_cmd_rpm__installed_packages() | ||
{ | ||
if [[ -r /var/log/rpmpkgs && | ||
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then | ||
|
@@ -38,13 +43,20 @@ _comp_cmd_rpm__macros() | |
-- "$cur")) | ||
} | ||
|
||
# shellcheck disable=SC2120 | ||
_comp_cmd_rpm__buildarchs() | ||
{ | ||
COMPREPLY=($(compgen -W "$("${1:-rpm}" --showrc | command sed -ne \ | ||
's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p')" \ | ||
-- "$cur")) | ||
} | ||
|
||
# shellcheck disable=SC2120 | ||
_comp_cmd_rpm__configdir() | ||
{ | ||
cfgdir=$("${1:-rpm}" --eval '%{_rpmconfigdir}' 2>/dev/null) | ||
} | ||
|
||
# rpm(8) completion | ||
# | ||
_comp_cmd_rpm() | ||
|
@@ -147,7 +159,7 @@ _comp_cmd_rpm() | |
_comp_compgen -- -W '"${opts[@]}" --allmatches --noscripts | ||
--notriggers --nodeps --test --repackage' | ||
else | ||
_comp_xfunc_rpm_installed_packages "$1" | ||
_comp_cmd_rpm__installed_packages "$1" | ||
fi | ||
;; | ||
-q* | --query) | ||
|
@@ -190,7 +202,7 @@ _comp_cmd_rpm() | |
--whatrecommends --whatrequires --whatsuggests | ||
--whatsupplements' | ||
elif [[ ${words[*]} != *\ -@(*([^ -])a|-all )* ]]; then | ||
_comp_xfunc_rpm_installed_packages "$1" | ||
_comp_cmd_rpm__installed_packages "$1" | ||
fi | ||
fi | ||
;; | ||
|
@@ -216,14 +228,14 @@ _comp_cmd_rpm() | |
elif [[ ${words[*]} == *\ -@(*([^ -])p|-package )* ]]; then | ||
_comp_compgen_filedir '[rs]pm' | ||
else | ||
_comp_xfunc_rpm_installed_packages "$1" | ||
_comp_cmd_rpm__installed_packages "$1" | ||
fi | ||
;; | ||
--resign | --addsign | --delsign) | ||
_comp_compgen_filedir '[rs]pm' | ||
;; | ||
--setperms | --setgids) | ||
_comp_xfunc_rpm_installed_packages "$1" | ||
_comp_cmd_rpm__installed_packages "$1" | ||
;; | ||
--import | --dbpath | --root) | ||
if [[ $cur == -* ]]; then | ||
|
@@ -242,30 +254,33 @@ _comp_cmd_rpmbuild() | |
local cur prev words cword was_split comp_args | ||
_comp_initialize -s -- "$@" || return | ||
|
||
local rpm="${1%build*}" | ||
[[ $rpm == "$1" ]] || ! type "$rpm" &>/dev/null && rpm= | ||
|
||
local noargopts='!(-*|*[rED]*)' | ||
# shellcheck disable=SC2254 | ||
# shellcheck disable=SC2119,SC2254 | ||
case $prev in | ||
--buildroot | --root | --dbpath | -${noargopts}r) | ||
_comp_compgen_filedir -d | ||
return | ||
;; | ||
--target | --eval | -${noargopts}E | --buildpolicy) | ||
# Prefer `rpm` in the same dir in utility functions | ||
local pathcmd | ||
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH | ||
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The benefit of prepending to In some cases we may want to pass the full path, that's still possible, but I suppose the |
||
;;& | ||
--target) | ||
_comp_cmd_rpm__buildarchs "$rpm" | ||
_comp_cmd_rpm__buildarchs | ||
return | ||
;; | ||
--eval | -${noargopts}E) | ||
_comp_cmd_rpm__macros "$rpm" | ||
_comp_cmd_rpm__macros | ||
return | ||
;; | ||
--macros | --rcfile) | ||
_comp_compgen_filedir | ||
return | ||
;; | ||
--buildpolicy) | ||
local cfgdir=$("$rpm" --eval '%{_rpmconfigdir}' 2>/dev/null) | ||
local cfgdir | ||
_comp_cmd_rpm__configdir | ||
if [[ $cfgdir ]]; then | ||
COMPREPLY=($(compgen -W "$(command ls "$cfgdir" 2>/dev/null | | ||
command sed -ne 's/^brp-//p')" -- "$cur")) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think this line should have also been updated as
[[ $2 == functions ]]
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scop Can you include it in #988?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, good catch, done in b85263a.