deploy: support des options -old pour afficher des informations supplémentaires

This commit is contained in:
Jephté Clain 2017-04-19 00:15:01 +04:00
parent 2daf190c60
commit c1a536be52
1 changed files with 34 additions and 18 deletions

View File

@ -30,14 +30,17 @@ function deploy_query_recursive() {
function deploy_query_once() {
# Afficher le résultat d'une requête
local alv
eval "set -- $(getopt -ov: -lallow-vars: -- "$@")"
local alv sov slv sdv
eval "set -- $(getopt -ov:old -lallow-vars:,object-vars,link-vars,dest-vars -- "$@")"
while [ -n "$1" ]; do
case "$1" in
-v|--allow-vars)
array_split alv "$2" ,
shift; shift
;;
-o|--object-vars) sov=1; shift;;
-l|--link-vars) slv=1; shift;;
-d|--dest-vars) sdv=1; shift;;
--) shift; break;;
*) break;;
esac
@ -50,7 +53,7 @@ function deploy_query_once() {
DEST|SOURCE)
if [ -n "$otype" ]; then
deploy_is_type "$otype" || {
qvals false "$otype: invalid type"
[ "$format" == shell ] && qvals false "$otype: invalid type"
return 2
}
fi
@ -58,7 +61,7 @@ function deploy_query_once() {
*)
if [ -n "$qtype" ]; then
deploy_is_type "$qtype" || {
qvals false "$qtype: invalid type"
[ "$format" == shell ] && qvals false "$qtype: invalid type"
return 3
}
fi
@ -66,12 +69,12 @@ function deploy_query_once() {
esac
if [ -n "$ltype" ]; then
deploy_is_link "$ltype" || {
qvals false "$ltype: invalid link type"
[ "$format" == shell ] && qvals false "$ltype: invalid link type"
return 4
}
fi
[ -n "$term" ] || {
qvals false "search term required"
[ "$format" == shell ] && qvals false "search term required"
return 5
}
@ -80,25 +83,40 @@ function deploy_query_once() {
edebug "=== search type DEST"
edebug "term=$term, otype=$otype"
deploy_search_artifact object type "$term" "$otype" host || {
qvals false "artifact not found"
[ "$format" == shell ] && qvals false "artifact not found"
return 1
}
edebug "object=$object, type=$type"
deploy_search_link link "$type" "$ltype" || {
qvals false "link not found"
[ "$format" == shell ] && qvals false "link not found"
return 1
}
deploy_show_values object object "$format" shell alv
deploy_show_values type otype "$format" shell alv
deploy_show_values link ltype "$format" shell alv
deploy_show_links "$object" "$link" "$profile" "$format" "" alv
echo true
if [ -n "$sov" ]; then
deploy_copy_object_values vs "$object" "$type"
deploy_show_values vs "$type" "$format" shell alv
deploy_show_attrs "$object" "$type" "$format" alv vars
fi
if [ -n "$sdv" ]; then
local -a pons pgns ons gns ans ovs os; local an av o
deploy_prepare_copy_link_attrs pons pgns ons gns "$object" "$link" "$profile"
deploy_copy_link_attr_values hvs host "$object" "$link" "$profile" pons pgns ons gns
for hv in "${hvs[@]}"; do
deploy_copy_object_values hs "$hv" host
deploy_show_values hs host "$format" shell alv
deploy_show_attrs "$hn" host "$format" alv vars
done
fi
deploy_show_links "$object" "$link" "$profile" "$format" "" alv vars
[ "$format" == shell ] && echo true
return 0
;;
SOURCE)
# XXX implémenter
echo true
[ "$format" == shell ] && echo true
return 0
;;
*)
@ -108,10 +126,10 @@ function deploy_query_once() {
deploy_show_values type otype "$format" shell alv
deploy_show_values vs "$type" "$format" "" alv
deploy_show_attrs "$object" "$type" "$format" alv
echo true
[ "$format" == shell ] && echo true
return 0
fi
qvals false "artifact not found"
[ "$format" == shell ] && qvals false "artifact not found"
return 1
;;
esac
@ -250,10 +268,7 @@ function deploy_show_values() {
[ -n "$ff" -a "$f" != "$ff" ] && return
case "$f" in
shell)
[ -n "$5" ] && echo "$t=()"
deploy_dump_values "$t" vs
;;
shell) deploy_dump_values "$t" vs;;
line) array_to_lines vs;;
*) array_join vs "$f";;
esac
@ -270,12 +285,12 @@ function deploy_show_attrs() {
local -a ons gns ans vs; local an
deploy_prepare_copy_attrs ons gns "$o" "$t"
deploy_copy_attr_names ans "$o" "$t" ons gns
[ -n "$5" ] && echo_seta "${t}_vars" "${ans[@]}"
for an in "${ans[@]}"; do
if [ -n "$4" ]; then
if ! array_isempty "$4"; then
array_contains alv "$an" || continue
fi
[ "$f" == shell ] && echo "$an=()"
fi
deploy_copy_attr_values vs "$an" "$o" "$t" ons
deploy_dump_values "$an" vs
@ -298,6 +313,7 @@ function deploy_show_links() {
deploy_prepare_copy_link_attrs pons pgns ons gns "$o" "$l" "$p"
deploy_copy_link_attr_names ans "$o" "$l" "$p" pons pgns ons gns
[ -n "$7" -a "$f" == shell ] && echo_seta "${l}_vars" "${ans[@]}"
for an in "${ans[@]}"; do
deploy_copy_link_attr_values avs "$an" "$o" "$l" "$p" pons pgns ons gns
if [ "$an" == host ]; then