mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-03 18:16:17 +01:00
Merge branch 'bmwiedemann-completion'
Patches by Werner Fink <werner@suse.de>.
This commit is contained in:
commit
cbe2c47bd6
1
dist/complete.sh
vendored
1
dist/complete.sh
vendored
@ -1,7 +1,6 @@
|
||||
test -z "$BASH_VERSION" && return
|
||||
complete -o default _nullcommand >/dev/null 2>&1 || return
|
||||
complete -r _nullcommand >/dev/null 2>&1 || return
|
||||
COMP_WORDBREAKS="${COMP_WORDBREAKS//:}"
|
||||
test -s /usr/share/osc/complete && complete -o default -C /usr/share/osc/complete osc
|
||||
test -s /usr/lib64/osc/complete && complete -o default -C /usr/lib64/osc/complete osc
|
||||
test -s /usr/lib/osc/complete && complete -o default -C /usr/lib/osc/complete osc
|
||||
|
107
dist/osc.complete
vendored
Normal file → Executable file
107
dist/osc.complete
vendored
Normal file → Executable file
@ -6,7 +6,6 @@
|
||||
#
|
||||
# usage with bash
|
||||
#
|
||||
# COMP_WORDBREAKS="${COMP_WORDBREAKS//:}"
|
||||
# complete -C osc.complete osc
|
||||
#
|
||||
# Author: Werner Fink <werner@suse.de>
|
||||
@ -35,14 +34,19 @@ if test "/proc/$PPID/exe" -ef /bin/tcsh ; then
|
||||
let colon=0
|
||||
else
|
||||
COMMAND_LINE="${COMP_LINE:0:$COMP_POINT}"
|
||||
# let colon=1
|
||||
let colon=0
|
||||
case "$COMP_WORDBREAKS" in
|
||||
*:*) let colon=1
|
||||
esac
|
||||
[[ $COMMAND_LINE =~ \\: ]] && COMMAND_LINE="${COMMAND_LINE//\\:/:}"
|
||||
fi
|
||||
IFS="${IFS}="
|
||||
cmdline=($COMMAND_LINE)
|
||||
IFS="$OIFS"
|
||||
test "${cmdline[0]}" != "osc" && exit 1
|
||||
case "${cmdline[0]}" in
|
||||
iosc|isc|osc) ;;
|
||||
*) exit 1
|
||||
esac
|
||||
|
||||
let last=${#COMMAND_LINE}
|
||||
let last--
|
||||
@ -79,24 +83,64 @@ oscprj=""
|
||||
oscpkg=""
|
||||
lnkprj=""
|
||||
lnkpkg=""
|
||||
apiurl=""
|
||||
alias=""
|
||||
test -s ${PWD}/.osc/_project && read -t 1 oscprj < ${PWD}/.osc/_project
|
||||
test -s ${PWD}/.osc/_package && read -t 1 oscpkg < ${PWD}/.osc/_package
|
||||
if test -s ${PWD}/.osc/_files ; then
|
||||
lnkprj=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]project="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files)
|
||||
lnkpkg=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]package="([^"]+)".*@\1@p;}' < ${PWD}/.osc/_files)
|
||||
fi
|
||||
if test -s ${PWD}/.osc/_apiurl ; then
|
||||
read apiurl < ${PWD}/.osc/_apiurl
|
||||
alias=$(sed -rn '\@^\['${apiurl}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < ~/.oscrc 2> /dev/null)
|
||||
fi
|
||||
if test "${cmdline[0]}" = isc ; then
|
||||
alias=internal
|
||||
fi
|
||||
|
||||
if test -s ~/.osc.projects ; then
|
||||
typeset -i ctime=$(command date -d "$(command stat -c '%z' ~/.osc.projects)" +'%s')
|
||||
projects=~/.osc.projects
|
||||
command=osc
|
||||
|
||||
case "${cmdline[1]}" in
|
||||
-A|--apiurl)
|
||||
if test -n "${cmdline[2]}" -a -s ~/.oscrc ; then
|
||||
hints=($(sed -rn '/^(aliases=|\[http)/{s/,/ /g;s/(aliases=|\[|\])//gp}' < ~/.oscrc 2> /dev/null))
|
||||
for h in ${hints[@]} ; do
|
||||
case "$h" in
|
||||
http*)
|
||||
tmp=$(sed -rn '\@^\['${h}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < ~/.oscrc 2> /dev/null)
|
||||
if test "${cmdline[2]}" = "$h" ; then
|
||||
alias=$tmp
|
||||
break
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if test "${cmdline[2]}" = "$h" ; then
|
||||
alias=$h
|
||||
break
|
||||
fi
|
||||
esac
|
||||
done
|
||||
fi
|
||||
esac
|
||||
|
||||
if test -n "$alias" ; then
|
||||
projects="${projects}.${alias}"
|
||||
command="$command -A $alias"
|
||||
fi
|
||||
|
||||
if test -s "${projects}" ; then
|
||||
typeset -i ctime=$(command date -d "$(command stat -c '%z' ${projects})" +'%s')
|
||||
typeset -i now=$(command date -d now +'%s')
|
||||
if ((now - ctime > 86400)) ; then
|
||||
if tmp=$(mktemp ~/.osc.projects.XXXXXX) ; then
|
||||
command osc ls / >| $tmp
|
||||
mv -uf $tmp ~/.osc.projects
|
||||
if tmp=$(mktemp ${projects}.XXXXXX) ; then
|
||||
command ${command} ls / >| $tmp
|
||||
mv -uf $tmp ${projects}
|
||||
fi
|
||||
fi
|
||||
else
|
||||
command osc ls / >| ~/.osc.projects
|
||||
command ${command} ls / >| "${projects}"
|
||||
fi
|
||||
|
||||
projects ()
|
||||
@ -104,7 +148,7 @@ projects ()
|
||||
local -a list
|
||||
local -a argv
|
||||
local -i argc=0
|
||||
local arg
|
||||
local arg cur
|
||||
for arg; do
|
||||
if test $arg == "--" ; then
|
||||
let argc++
|
||||
@ -113,15 +157,18 @@ projects ()
|
||||
argv[argc++]=$arg
|
||||
done
|
||||
shift $argc
|
||||
if test -n "$1" ; then
|
||||
list=($(command grep -E "^$1" ~/.osc.projects))
|
||||
cur="$1"
|
||||
if test -n "${cur}" ; then
|
||||
list=($(command grep -E "^${cur}" ${projects}))
|
||||
else
|
||||
list=($(command cat ~/.osc.projects))
|
||||
list=($(command cat ${projects}))
|
||||
fi
|
||||
if ((colon)) ; then
|
||||
builtin compgen -W "${list[*]}" "$1"|sed -r 's@([^\\]):@\1\\:@g'
|
||||
local colon_word
|
||||
colon_word=${cur%${cur##*:}}
|
||||
builtin compgen -W "${list[*]}" -- "${cur}" | sed -r "s@^${colon_word}@@g"
|
||||
else
|
||||
builtin compgen -W "${list[*]}" -- ${1+"$@"}
|
||||
builtin compgen -W "${list[*]}" -- "${cur}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -130,7 +177,7 @@ packages ()
|
||||
local -a list
|
||||
local -a argv
|
||||
local -i argc=0
|
||||
local arg
|
||||
local arg cur
|
||||
for arg; do
|
||||
if test $arg == "--" ; then
|
||||
let argc++
|
||||
@ -139,12 +186,13 @@ packages ()
|
||||
argv[argc++]=$arg
|
||||
done
|
||||
shift $argc
|
||||
if test -n "$1" ; then
|
||||
list=($(command osc ls ${argv[@]}|command grep -E "^$1"))
|
||||
cur="$1"
|
||||
if test -n "${cur}" ; then
|
||||
list=($(command ${command} ls ${argv[@]}|command grep -E "^${cur}"))
|
||||
else
|
||||
list=($(command osc ls ${argv[@]}))
|
||||
list=($(command ${command} ls ${argv[@]}))
|
||||
fi
|
||||
builtin compgen -W "${list[*]}" -- ${1+"$@"}
|
||||
builtin compgen -W "${list[*]}" -- "${cur}"
|
||||
}
|
||||
|
||||
repositories ()
|
||||
@ -162,11 +210,11 @@ repositories ()
|
||||
done
|
||||
shift $argc
|
||||
if test -n "$1" ; then
|
||||
list=($(command osc meta prj ${argv[@]}|\
|
||||
list=($(command ${command} meta prj ${argv[@]}|\
|
||||
command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
|
||||
command sort -u|command grep -E "^$1"))
|
||||
else
|
||||
list=($(command osc meta prj ${argv[@]}|\
|
||||
list=($(command ${command} meta prj ${argv[@]}|\
|
||||
command sed -rn '/<repository/{s@^\s*<.*name="([^"]*)".*@\1@p}'|\
|
||||
command sort -u))
|
||||
fi
|
||||
@ -188,11 +236,11 @@ architectures ()
|
||||
done
|
||||
shift $argc
|
||||
if test -n "$1" ; then
|
||||
list=($(command osc meta prj ${argv[@]}|\
|
||||
list=($(command ${command} meta prj ${argv[@]}|\
|
||||
command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
|
||||
command sort -u|command grep -E "^$1"))
|
||||
else
|
||||
list=($(command osc meta prj ${argv[@]}|\
|
||||
list=($(command ${command} meta prj ${argv[@]}|\
|
||||
command sed -rn '/<arch>/{s@^\s*<arch>(.*)</arch>@\1@p}'|\
|
||||
command sort -u))
|
||||
fi
|
||||
@ -223,8 +271,8 @@ targets ()
|
||||
|
||||
users ()
|
||||
{
|
||||
if test -s ~/.osc.projects ; then
|
||||
command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ~/.osc.projects|command sort -u
|
||||
if test -s ${projects} ; then
|
||||
command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ${projects}|command sort -u
|
||||
elif test -s ~/.oscrc; then
|
||||
command sed -rn '/^(user=)/{s/(user=)//p}' ~/.oscrc|command sort -u
|
||||
else
|
||||
@ -350,7 +398,7 @@ add|addremove|ar)
|
||||
fi
|
||||
;;
|
||||
build)
|
||||
opts=(--help --oldpackages --disable-cpio-bulk-download --download-api-only --release --baselibs
|
||||
opts=(--help --oldpackages --disable-cpio-bulk-download --release --baselibs
|
||||
--disable-debuginfo --debuginfo --alternative-project --vm-type --linksources
|
||||
--local-package --build-uid --userootforbuild --define --without --with
|
||||
--ccache --icecream --jobs --root --extra-pkgs --keep-pkgs --prefer-pkgs
|
||||
@ -437,9 +485,8 @@ build)
|
||||
done
|
||||
fi
|
||||
if ((count == 2)) ; then
|
||||
specs=($(command ls *.spec 2>/dev/null))
|
||||
images=($(command ls *.kiwi 2>/dev/null))
|
||||
builtin compgen -W "${opts[*]} ${specs[*]} ${images[*]}" -- "${cmdline[count]}"
|
||||
specs=($(command ls *.spec))
|
||||
builtin compgen -W "${opts[*]} ${specs[*]}" -- "${cmdline[count]}"
|
||||
fi
|
||||
;;
|
||||
branch|getpac|bco|branchco)
|
||||
|
Loading…
Reference in New Issue
Block a user