nulib/bash/tests/test-output.sh

170 lines
3.9 KiB
Bash
Raw Normal View History

2023-10-17 23:40:19 +04:00
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
2023-10-20 10:30:12 +04:00
source "$(dirname -- "$0")/../src/nulib.sh" || exit 1
#NULIB_NO_DISABLE_SET_X=1
2023-10-17 23:40:19 +04:00
2024-03-27 04:25:09 +04:00
Multiline=
Banner=
2023-10-21 19:49:06 +04:00
args=(
"afficher divers messages avec les fonctions e*"
2024-03-27 04:37:42 +04:00
-D,--debug '$set_debug'
2023-10-21 19:49:06 +04:00
-d,--date NULIB_ELOG_DATE=1
-m,--myname NULIB_ELOG_MYNAME=1
2024-03-27 04:25:09 +04:00
-n,--nc,--no-color '$__set_no_colors 1'
--ml Multiline=1
-b Banner=1
2023-10-21 19:49:06 +04:00
)
parse_args "$@"; set -- "${args[@]}"
2024-03-27 04:25:09 +04:00
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
2024-03-27 04:37:42 +04:00
function vtrue() {
echo "commande qui se termine avec succès"
}
function vfalse() {
echo "commande qui se termine en échec"
return 1
}
2024-03-27 04:25:09 +04:00
edesc "action avec commande"
2024-03-27 04:37:42 +04:00
action "commande true" vtrue
action "commande false" vfalse
2024-03-27 04:25:09 +04:00
edesc "action avec commande et aresult sans message"
action "commande true"
2024-03-27 04:37:42 +04:00
vtrue; aresult $?
2024-03-27 04:25:09 +04:00
action "commande false"
2024-03-27 04:37:42 +04:00
vfalse; aresult $?
2024-03-27 04:25:09 +04:00
edesc "action avec commande et aresult"
action "commande true"
2024-03-27 04:37:42 +04:00
vtrue; aresult $? "résultat de la commande"
2024-03-27 04:25:09 +04:00
action "commande false"
2024-03-27 04:37:42 +04:00
vfalse; aresult $? "résultat de la commande"
2024-03-27 04:25:09 +04:00
fi