Différences entre les versions de « Auto-éditer un wikilivre/Annexer (Version internationalisée)/src/annex.sh »

m
Mise à jour
m (WL:RD : * diverses retouches)
m (Mise à jour)
{{remarqueampoule|{{rouge|incomplet en raison de l'absence des commandes compose.}}<br />testabble jusqu'à la commande listsclt.sh inclue.}}
# <syntaxhighlight lang="bash">
#!/bin/bash
#H File : annex and-or annex.sh
#H Version initiale : 2020-05-24
#H Syntax : annex [ <book-name> || ? ] [ -v ] [ -pb || -pc ]
#H Example : ./annex TestBook (on the terminal for unit tests)
#H Updated : 2020-05-15 by GC
#H Updated : 2020-05-24 by GC to translate
#H Updated : 2021-0304-1602 by User GC
#H Last update : 2021-04-22 for tests in tests dir 2-annex.sh
#H Update on fr:Wikibooks : 2021-03-26 incomplet
#H
#P
#P export ~/Add_appendix/bin for this session only
#T export PATH=$PATH:~/Add_appendix/bin
#T env | grep Add_appendix
 
. gettext.sh
 
VERSION=210616
Version=210326
if [ "$1" = "--v" ]; then echo "Annex version $VERSION"; exit 0; echo; fi
 
ADD_APPENDIX=$HOME/Add_appendix
#P if first param is empty print the syntax and exit
 
#P ifIf first param is empty print the syntax and exit
if [ -z $1 ]
then
echo "$(gettext ' No Parameter ')"
echo "$(gettext ' Syntax : ~/Add-appendix/bin/annex [ <book-name/contents url> | <Collections/book url> | ? ] [ -v ] [ -pb | -pc ] ')";
exit 0;
fi
#P ifIf help whis the '?' character
if [ "$1" = "?" ]
then
clear
echo "$(gettext ' Syntax : ')"
echo "$(gettext ' annex [ <book-name/contents url> | <collections/book url> | ? ] [ -v ] [ -pb | -pc ] ')"
echo "$(gettext ' Options : ')"
echo "$(gettext ' annex ?, to display the command syntax. ')"
fi
 
if [ -de share~/Add_appendix/vars/installdir.var ];
then
source ~/Add_appendix/vars/installdir.var
echo "Sharedirdatas/installdir.var is OKfound in annex command"; echo
read Sharedir < sharedir.txt
echo Bindir=$SharedirInstalldir/bin
Testsdir=$Workdir/tests
read Workdir < $Sharedir/workdir.txt
read Bindir < $Sharedir/bindir.txt
read Libdir < $Sharedir/libdir.txt
read Project < $Sharedir/project.txt
else
echo -n "current directory in $0 "
pwd
echo "Sharedir~/Add_appendix/vars/installdir.var not found in $0 command"
exit -1
fi
 
#T echo "Install directory = $Installdir"
#P include header.inc in binary environnment ~/Add_appendix/bin
#T echo "Working directory = $Workdir"
source $Bindir/header.inc
#T echo "Bin directory = $Bindir"
#T echo "Tests directory = $Testsdir"
#T Test break exit 0
 
#P includeInclude header.inc in binary environnment ~/Add_appendix/bin
if test -e "$Bindir/header.inc"
then
echo "header.inc found in $Bindir"
source $Bindir/header.inc
else echo "copy header.inc to $Bindir to continue"; exit -1
fi
#T spottingSpotting
echo "*** 'annex' command ***"
#T Test env | grep Add_appendix
#T echo "Installdir : "$Installdir
 
#P initializingInitializing modes
Verbose="false"
Personal="false"
Personalwb="false"
Personalco="false"
#T Breakpoint exit 0
if (("$#" > "1"))
then
fi
 
#P printingPrint variables from the command line
echo "$(gettext ' The variable Verbose is initialised at : ')"$Verbose
echo "$(gettext ' The variable Personalwb is initialised at : ')"$Personalwb
echo "$(gettext ' The variable Personal is initialised at : ')"$Personal
echo ""
#T Test break exit 0
 
#P printPrint files in project directorie, and delete the files according to the answer
echo "$(gettext ' -Command annex- Files in project directory : ')"
ls $Project
else echo "$(gettext ' No file deletion ! ... Continue ... ')"
fi
echo "WAIT ..."
if test -d $Workdir/Verbosetemp/Report-verbose-mode; then rm $Workdir/Verbosetemp/Report-verbose-mode/*.txt; echo -n "" ; else mkdir $Workdir/Verbosetemp//Report-verbose-mode; fi;
if test -d $Workdir/Silenttemp/Report-silent-mode; then rm $Workdir/Silenttemp/Report-silent-mode/*.txt; echo -n "" ; else mkdir $Workdir/Silenttemp/Report-silent-mode; fi;
#T Print Install directory echo "Installdir : in annex command : $Installdir"
 
#P runningRunning list.sh
if [ $Verbose = "true" ]
then $Bindir/list.sh $1
else $Bindir/list.sh $1 > $Workdir/Silenttemp/Report-silent-mode/list-cmd.txt
fi
#P returnReturn value from list.sh
Return=$?
if [ $Return -gt '0' ]
then
echo "$(gettext ' Error in shell module list in silent mode. See See Silent$Workdir/temp/Report-silent-mode/list-cmd.txt ')"
exit 1
fi
#T Breakpoint exit 0
#T
exit
 
#P runningRunning downloads.sh
if [ $Verbose = "true" ]
then $Bindir/download.sh $1
else $Bindir/download.sh $1 > $Workdir/Silenttemp/Report-silent-mode/download-cmd.txt
fi
#P returnReturn value from downloads.sh
Return=$?
if [ $Return -gt '0' ]
then
echo "$(gettext ' Error in shell module download in silent mode. See See Silent$Workdir/temp/Report-silent-mode/download-cmd.txt ')"
exit 1
fi
 
#P runningRunning add_sclt.sh
if [ $Verbose = "true" ]
then
$Bindir/add_sclt.sh $1
else
$Bindir/add_sclt.sh $1 > $Workdir/Silenttemp/Report-silent-mode/add_sclt-cmd.txt
fi
#P returnReturn value from add_sclt.sh
Return=$?
if [ $Return -gt '0' ]
then
echo "$(gettext ' Error in shell module add-sclt in silent mode. See See Silent$Workdir/temp/Report-silent-mode/add_sclt-cmd.txt ')"
exit 1
fi
#T test break
 
exit 0
#P runningRunning add_sclic.sh
if [ $Personal = "false" ]
then
if [ $Verbose = "true" ]
then
$Bindir/add_sclic.sh $1
else
$Bindir/add_sclic.sh $1 > $Workdir/SilentReport-silent-mode/add_sclic-cmd.txt
fi
cat $Project/$1.sclic > $Project/$1.scli
fi
#P returnReturn value from add_sclic
Return=$?
if [ $Return -gt '0' ] && [ $Personal = "false" ];
fi
#P ifIf option -pc is validated, running sclipco.sh
if [ "$Personalco" == "true" ]
then
if [ "$Verbose" == "true" ]; then .$Bindir/sclipco.sh $1; else .$Bindir/sclipco.sh $1 > $Workdir/SilentReport-silent-mode/sclipco-cmd.txt; fi;
echo "$(gettext ' sclipco.sh has been executed ')";
fi
#P returnReturn value from slipco.sh
Return=$?
if [ $Return -gt '0' ] && [ $Personalpc = "true" ];
fi
#P ifIf option -pb is validated, running sclipw
if [ "$Personalwb" == "true" ]
then
if [ "$Verbose" == "true" ]; then .$Bindir/sclipwb.inc $1; else .$Bindir/sclipwb.inc $1 > $Workdir/SilentReport-silent-mode/scliwb-cmd.txt; fi;
echo "$(gettext ' sclipwb.sh has been executed ')";
fi
if [ $Return -gt '0' ] && [ $Personalwb = "true" ];
fi
 
#P Flush article, source lisence ant text to project.appendix
#P in project :
cd $Project
cat $1.sclt > $1.appendix
 
#P ? sclip.inc ...?
# if [ $Personal == "true" ]
# then cat $Project/$1.sclip >> $Project/$1.appendix; echo "$(gettext ' $1.sclip is copiedadded to $1.appendix ')";
# else
# cat $1.sclic >> $1.appendix; echo "$(gettext ' $1.sclic is copied to $1.appendix ')";
# fi
 
echo "$(gettext ' == License == ')" >> $1.appendix
cat $1/$1.license >> $1.appendix
echo "" >> $1.appendix
#P echo "{{Nouvelle page imprimée}}" >> $1.appendix
#P echo "{{Page-break/end}}" on en:wikibooks >> $1.appendix
echo "$(gettext ' <br style=\"page-break-after: always\"> ')" >> $1.appendix