« Auto-éditer un wikilivre/addappendix/reconstruction et tests du script addappendix » : différence entre les versions
Contenu supprimé Contenu ajouté
WL:RD : Initialisation de la page |
(Aucune différence)
|
Version du 14 janvier 2022 à 12:45
- Cette page concerne le logiciel addappendix mis en paquet
script addapendix.sh
#!/bin/bash
#H Header doc
#H -------------------------------
#H File : tests/addappendix/addapendix.sh
#H Syntax : addapendix [ ? | -v ]
#H Created : 220113 by GC
#H Updated : 220113 by ... for
#O Organizational chart
#O -------------------------------
#P Programmers notes
#P -------------------------------
VERSION=220113
TEXTDOMAIN=addappendix
TEXTDOMAINDIR="/usr/share/locale"
export TEXTDOMAINDIR
#P . gettext for translation
. gettext.sh
#O Script begin here
#O If parameters is empty
if test -z $1
#O Then print the short syntax ant exit -1
then
echo $"No parameter. addappendix [ <full url of book> | ? | -v ]"
exit -1
fi
#O If firt parameter is '?'
if [ "$1" = "?" ]
#O Then print syntax whih examples and exit 0
then
echo $"Syntax: addappendix [ <full url of book> | -v ]"
echo $"Example 1 : addappendix https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix"
echo $"Example 2 : addappendix https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel"
exit 0
fi
#O IF first parameter is "-v"
if [ "$1" = "-v" ]
#O Then print addapendix version
then
echo $"addapendix version : $VERSION"
exit 0
fi
#O *** First parameter analysis ***
#O Test if the first parameter points to wikibooks.org/wiki
if echo $1 | grep wikibooks.org/wiki
then
echo "OK for wikibooks.org/wiki"
else
echo "$1 is not a book on wikibooks"
exit -1
fi
#O Check if $1 file exist
if wget --spider $1 2>/dev/null; then
echo "File $1 exists"
else
echo "File $1 does not exist"
exit -1
fi
#O Find the bookname
echo $1 | awk -F"/" ' { print $NF }' > bookname.txt
read BOOKNAME<bookname.txt
echo "Book name : $BOOKNAME"
#O Create Bookname diredtory
install -d ~/Add_appendix/books/$BOOKNAME
#O Télécharger la page compilée
cd ~/Add_appendix/books/$BOOKNAME
wget -r -linif -k -p -E -i $1
exit 0
#O Script end
script tests_addappendix.bash
#!/bin/bash
#H Header doc
#H -------------------------------
#H File : tests/addappendix/tests_addapendix.bash
#H Syntax : ./tests_addapendix.bash
#H Created : 220113 by GC
#H Updated : 220113 by ... for
#O Organizational chart
#O -------------------------------
#P Programmers notes
#P -------------------------------
echo "test first param empty"
./addappendix.sh
sleep 3
echo "----"
echo "test first param = '?'"
./addappendix.sh ?
sleep 3
echo "----"
echo "test first param = '-v'"
./addappendix.sh -v
sleep 3
echo "----"
echo "test with param = https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel"
./addappendix.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel