From 513fd3664fdaee848ff9a01c2bf654677025a580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Fri, 21 Jul 2023 23:45:45 +0300 Subject: [PATCH] Fetch repository architectures in zsh completition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Björn Bidar --- contrib/osc.zsh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/contrib/osc.zsh b/contrib/osc.zsh index 8ac714c8..7d495a1c 100644 --- a/contrib/osc.zsh +++ b/contrib/osc.zsh @@ -160,16 +160,35 @@ _osc_project_repositories() { fi } +_osc_project_repositories_arches() { + if [ ! -s $PWD/.osc/_build_repositories ] || \ + _osc_call_me_maybe $PWD/.osc/_build_repositories ; then + osc repositories > /dev/null + fi + # Just check if file exist in case the call to the api failed + if [ -s $PWD/.osc/_build_repositories ] ; then + grep -- $1 $PWD/.osc/_build_repositories | while read build_repository ; do + # Only output second word of each line + echo ${build_repository#*\ } + done | sort -u + fi +} + + _osc_cmd_getbinaries() { if [ "$words[2]" = "-" ]; then _osc_complete_help_commands 'options' 'option' return else + if [ -n "$words[2]" ] ; then + local osc_project_repository_arch=$(_osc_project_repositories_arches \ + "${words[2]}") + fi _arguments \ '1:PROJECT:( `cat $osc_projects` )' \ '2:PACKAGE:(PACKAGE)' \ '3:REPOSITORY:( `_osc_project_repositories`' \ - '4:ARCHITECTURE:(i586 x86_64)' + '4:ARCHITECTURE:(`echo $osc_project_repository_arch`)' fi } @@ -189,9 +208,13 @@ _osc_cmd_buildlog() { _osc_complete_help_commands 'options' 'option' return else + if [ -n "$words[2]" ] ; then + local osc_project_repository_arch=$(_osc_project_repositories_arches \ + "${words[2]}") + fi _arguments \ '1:REPOSITORY:( `_osc_project_repositories` )' \ - '2:ARCHITECTURE:(i586 x86_64)' + '2:ARCHITECTURE:(`echo $osc_project_repository_arch`)' fi }