Skip to content
Extraits de code Groupes Projets
Valider e4d31c49 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Update commands

- Add the -np flag for 'not present'
- Add a pack only if it's in the sticker picker folder
- Rename the command get to add
- Add env to suppress messages
- Update help string
parent 0a7060e5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -15,6 +15,12 @@ else
info() { echo 'INFO:' $* >/dev/stderr; }
fi
if [ "x$STPKG_NO_MSG" = "xyes" ]; then
error() { return 0; }
warn() { return 0; }
info() { return 0; }
fi
########################
# Some basic functions #
########################
......@@ -28,18 +34,20 @@ usage() {
cat << EOF
$0 usage:
$0 update
$0 list [-p -e] [bash regex]
$0 get <pack>
$0 list [-p -e -np] [bash regex]
$0 add <pack>
$0 del <pack>
Flags:
-e The pack is enabled
-p The pack is present in the sticker repo
-np The pack is not present in the sticker repo
ENV variables:
STPKG_INSTALL The cloned stickerpicker project location. Defaut is ~/html/stickerpicker.
STPKG_BASE Where the sticker project is located.
STPKG_COLORS Use colors for output. Default is 'yes'.
STPKG_INSTALL [path] The cloned stickerpicker project location. Defaut is ~/html/stickerpicker.
STPKG_BASE [path] Where the sticker project is located.
STPKG_COLORS ['yes'|'no'] Use colors for output. Default is 'yes'.
STPKG_NO_MSG ['yes'|'no'] Disable messages, no 'info', 'warn' or 'error'. Default is 'no'.
The STPKG_INSTALL STPKG_BASE should have been given by the 'install.sh' script.
EOF
......@@ -107,16 +115,20 @@ alias ls=$__ls
__update() {
info "Updating packs..."
info "... update the sticker repo"
local LOCATION_OPT="--git-dir=$STPKG_BASE/.git --work-tree=$STPKG_BASE/"
git $LOCATION_OPT fetch || die "Failed to fetch from sticker repo"
git $LOCATION_OPT rebase || die "Failed to rebase... what did you do to your master branch?"
info "... update the sticker picker repo"
local LOCATION_OPT="--git-dir=$STPKG_INSTALL/.git --work-tree=$STPKG_INSTALL/"
git $LOCATION_OPT fetch || die "Failed to fetch from stickerpicker repo"
git $LOCATION_OPT rebase || die "Failed to rebase... what did you do to the master branch of the sticker picker?"
info "... copy the Json pack files in the sticker picker folder"
cp $STPKG_BASE/packs/*/*.json $STPKG_INSTALL/web/packs/ || die "Failed to copy packs Json files"
info "Update finished!"
}
......@@ -129,6 +141,10 @@ __list() {
local FILTER_ENABLED="yes"
shift
;;
-np)
local FILTER_NOT_PRESENT="yes"
shift
;;
-p)
local FILTER_PRESENT="yes"
shift
......@@ -139,6 +155,9 @@ __list() {
esac
done
[ "x$FILTER_PRESENT" = "xyes" -a "x$FILTER_NOT_PRESENT" = "xyes" ] \
&& die "The -p and -np flags are incompatible"
# Get the regex
if [ "x$*" = "x" ]; then
REG=
......@@ -164,6 +183,7 @@ __list() {
local PRESENT=`find $STPKG_BASE/packs/ -type f -name "$LINE.json"`
[ "x$FILTER_PRESENT" = "xyes" -a "x$PRESENT" = "x" ] && continue
[ "x$FILTER_NOT_PRESENT" = "xyes" -a ! "x$PRESENT" = "x" ] && continue
PRESENT=`[ ! "x$PRESENT" = "x" ] && echo '[present]' || echo ' '`
local ENABLED=`jq -r ".packs | index( \"$LINE.json\") | ." < $STPKG_INSTALL/web/packs/index.json`
......@@ -174,9 +194,13 @@ __list() {
done
}
__get() {
[ "x$1" = "x" ] && die "You must specify a pack for the 'get' command"
__add() {
[ "x$1" = "x" ] && die "You must specify a pack for the 'add' command"
info "Enable pack '$1'"
local PRESENT=`find $STPKG_INSTALL/web/packs/ -type f -name "$1.json" | grep -v index.json`
[ "x$PRESENT" = "x" ] && die "Pack '$1' is not present"
jq ".packs += [\"$1.json\"]" \
< $STPKG_INSTALL/web/packs/index.json | sponge $STPKG_INSTALL/web/packs/index.json
}
......@@ -214,9 +238,9 @@ case "$1" in
shift
__list $*
;;
get)
add)
shift
__get $*
__add $*
;;
del)
shift
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter