nulib/bash/tests/test-output.sh

170 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname -- "$0")/../src/nulib.sh" || exit 1
#NULIB_NO_DISABLE_SET_X=1
Multiline=
Banner=
args=(
"afficher divers messages avec les fonctions e*"
-D,--debug '$set_debug'
-d,--date NULIB_ELOG_DATE=1
-m,--myname NULIB_ELOG_MYNAME=1
-n,--nc,--no-color '$__set_no_colors 1'
--ml Multiline=1
-b Banner=1
)
parse_args "$@"; set -- "${args[@]}"
if [ -n "$Multiline" ]; then
############################################################################
[ -n "$Banner" ] && ebanner $'multi-line\nbanner'
esection $'multi-line\nsection'
etitle $'multi-line\ntitle'
etitle $'another\ntitle'
edesc $'multi-line\ndesc'
[ -n "$Banner" ] && ebanner $'multi-line\nbanner'
eimportant $'multi-line\nimportant'
eattention $'multi-line\nattention'
eerror $'multi-line\nerror'
ewarn $'multi-line\nwarn'
enote $'multi-line\nnote'
einfo $'multi-line\ninfo'
eecho $'multi-line\necho'
edebug $'multi-line\ndebug'
action $'multi-line\naction'
asuccess
action $'multi-line\naction'
estep $'multi-line\nstep'
afailure
action $'multi-line\naction'
estep $'multi-line\nstep'
asuccess $'multi-line\nsuccess'
action $'multi-line\naction'
estep $'multi-line\nstep'
adone $'multi-line\nneutral'
eend
eend
else
############################################################################
[ -n "$Banner" ] && ebanner "banner"
eimportant "important"
eattention "attention"
eerror "error"
ewarn "warn"
enote "note"
einfo "info"
eecho "echo"
edebug "debug"
estep "step"
estepe "stepe"
estepw "stepw"
estepn "stepn"
estepi "stepi"
esection "section"
eecho "content"
etitle "title0"
etitle "title1"
eecho "print under title1"
eend
eecho "print under title0"
eend
edesc "action avec step"
action "action avec step"
estep "step"
asuccess "action success"
action "action avec step"
estep "step"
afailure "action failure"
action "action avec step"
estep "step"
adone "action neutral"
edesc "actions sans step"
action "action sans step"
asuccess "action success"
action "action sans step"
afailure "action failure"
action "action sans step"
adone "action neutral"
edesc "actions imbriquées"
action "action0"
action "action1"
action "action2"
asuccess "action2 success"
asuccess "action1 success"
asuccess "action0 success"
edesc "action avec step, sans messages"
action "action avec step, sans messages, success"
estep "step"
asuccess
action "action avec step, sans messages, failure"
estep "step"
afailure
action "action avec step, sans messages, done"
estep "step"
adone
edesc "action sans step, sans messages"
action "action sans step, sans messages, success"
asuccess
action "action sans step, sans messages, failure"
afailure
action "action sans step, sans messages, done"
adone
edesc "actions imbriquées, sans messages"
action "action0"
action "action1"
action "action2"
asuccess
asuccess
asuccess
function vtrue() {
echo "commande qui se termine avec succès"
}
function vfalse() {
echo "commande qui se termine en échec"
return 1
}
edesc "action avec commande"
action "commande true" vtrue
action "commande false" vfalse
edesc "action avec commande et aresult sans message"
action "commande true"
vtrue; aresult $?
action "commande false"
vfalse; aresult $?
edesc "action avec commande et aresult"
action "commande true"
vtrue; aresult $? "résultat de la commande"
action "commande false"
vfalse; aresult $? "résultat de la commande"
fi