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 ...@@ -15,6 +15,12 @@ else
info() { echo 'INFO:' $* >/dev/stderr; } info() { echo 'INFO:' $* >/dev/stderr; }
fi fi
if [ "x$STPKG_NO_MSG" = "xyes" ]; then
error() { return 0; }
warn() { return 0; }
info() { return 0; }
fi
######################## ########################
# Some basic functions # # Some basic functions #
######################## ########################
...@@ -28,18 +34,20 @@ usage() { ...@@ -28,18 +34,20 @@ usage() {
cat << EOF cat << EOF
$0 usage: $0 usage:
$0 update $0 update
$0 list [-p -e] [bash regex] $0 list [-p -e -np] [bash regex]
$0 get <pack> $0 add <pack>
$0 del <pack> $0 del <pack>
Flags: Flags:
-e The pack is enabled -e The pack is enabled
-p The pack is present in the sticker repo -p The pack is present in the sticker repo
-np The pack is not present in the sticker repo
ENV variables: ENV variables:
STPKG_INSTALL The cloned stickerpicker project location. Defaut is ~/html/stickerpicker. STPKG_INSTALL [path] The cloned stickerpicker project location. Defaut is ~/html/stickerpicker.
STPKG_BASE Where the sticker project is located. STPKG_BASE [path] Where the sticker project is located.
STPKG_COLORS Use colors for output. Default is 'yes'. 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. The STPKG_INSTALL STPKG_BASE should have been given by the 'install.sh' script.
EOF EOF
...@@ -107,16 +115,20 @@ alias ls=$__ls ...@@ -107,16 +115,20 @@ alias ls=$__ls
__update() { __update() {
info "Updating packs..." info "Updating packs..."
info "... update the sticker repo" info "... update the sticker repo"
local LOCATION_OPT="--git-dir=$STPKG_BASE/.git --work-tree=$STPKG_BASE/" 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 fetch || die "Failed to fetch from sticker repo"
git $LOCATION_OPT rebase || die "Failed to rebase... what did you do to your master branch?" git $LOCATION_OPT rebase || die "Failed to rebase... what did you do to your master branch?"
info "... update the sticker picker repo" info "... update the sticker picker repo"
local LOCATION_OPT="--git-dir=$STPKG_INSTALL/.git --work-tree=$STPKG_INSTALL/" 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 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?" 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" 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" cp $STPKG_BASE/packs/*/*.json $STPKG_INSTALL/web/packs/ || die "Failed to copy packs Json files"
info "Update finished!" info "Update finished!"
} }
...@@ -129,6 +141,10 @@ __list() { ...@@ -129,6 +141,10 @@ __list() {
local FILTER_ENABLED="yes" local FILTER_ENABLED="yes"
shift shift
;; ;;
-np)
local FILTER_NOT_PRESENT="yes"
shift
;;
-p) -p)
local FILTER_PRESENT="yes" local FILTER_PRESENT="yes"
shift shift
...@@ -139,6 +155,9 @@ __list() { ...@@ -139,6 +155,9 @@ __list() {
esac esac
done done
[ "x$FILTER_PRESENT" = "xyes" -a "x$FILTER_NOT_PRESENT" = "xyes" ] \
&& die "The -p and -np flags are incompatible"
# Get the regex # Get the regex
if [ "x$*" = "x" ]; then if [ "x$*" = "x" ]; then
REG= REG=
...@@ -164,6 +183,7 @@ __list() { ...@@ -164,6 +183,7 @@ __list() {
local PRESENT=`find $STPKG_BASE/packs/ -type f -name "$LINE.json"` local PRESENT=`find $STPKG_BASE/packs/ -type f -name "$LINE.json"`
[ "x$FILTER_PRESENT" = "xyes" -a "x$PRESENT" = "x" ] && continue [ "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 ' '` PRESENT=`[ ! "x$PRESENT" = "x" ] && echo '[present]' || echo ' '`
local ENABLED=`jq -r ".packs | index( \"$LINE.json\") | ." < $STPKG_INSTALL/web/packs/index.json` local ENABLED=`jq -r ".packs | index( \"$LINE.json\") | ." < $STPKG_INSTALL/web/packs/index.json`
...@@ -174,9 +194,13 @@ __list() { ...@@ -174,9 +194,13 @@ __list() {
done done
} }
__get() { __add() {
[ "x$1" = "x" ] && die "You must specify a pack for the 'get' command" [ "x$1" = "x" ] && die "You must specify a pack for the 'add' command"
info "Enable pack '$1'" 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\"]" \ jq ".packs += [\"$1.json\"]" \
< $STPKG_INSTALL/web/packs/index.json | sponge $STPKG_INSTALL/web/packs/index.json < $STPKG_INSTALL/web/packs/index.json | sponge $STPKG_INSTALL/web/packs/index.json
} }
...@@ -214,9 +238,9 @@ case "$1" in ...@@ -214,9 +238,9 @@ case "$1" in
shift shift
__list $* __list $*
;; ;;
get) add)
shift shift
__get $* __add $*
;; ;;
del) del)
shift 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