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

Add parsing and default values for sticker file manipulation

No functional changes
parent 871cdf3e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -276,6 +276,11 @@ STPKG_HOMESERV='matrix.org'
STPKG_TOKEN=''
STPKG_COLORS='yes'
STPKG_NO_MSG='no'
STPKG_MAX_HEIGHT=128
STPKG_MAX_WIDTH=256
STPKG_GENERATE_PREVIEW="no"
STPKG_IMAGE_TARGET_FILETYPE="png"
STPKG_ANIMATED_TARGET_FILETYPE="gif"
EOF
chmod 00600 $STPKG_CONF_FILE
......@@ -704,7 +709,7 @@ __pack() {
local WIDTH=$(file_get_width "$FILE")
local HEIGHT=$(file_get_height "$FILE")
# Get the names and extentions
# Get the names and extensions
local TYPE=$(file_get_type "$FILE")
local NAME=$(file_get_name "$FILE")
if [ "x$TYPE" != "xgif" ] && [ "x$TYPE" != "xpng" ]; then
......@@ -799,8 +804,62 @@ __do_command() {
read -sp "`__yellow 'Enter your access token:'`" STPKG_TOKEN
echo ''
fi
validate_token # Validate token, will exit if invalid
local PARSE_FLAGS=1
while [ $PARSE_FLAGS -eq 1 ]; do
case "$1" in
# Overwrite max width
-w|-width)
STPKG_MAX_WIDTH="$2"
shift 2
;;
# Overwrite max height
-h|-height)
STPKG_MAX_HEIGHT="$2"
shift 2
;;
# Do we need to resize/convert the files we are given?
-trust)
STPKG_TRUST_SOURCE="yes"
shift
;;
# What filetype do we want our image stickers to be?
-ti)
STPKG_IMAGE_TARGET_FILETYPE="$2"
shift 2
;;
# What filetype do we want our animated stickers to be?
-ta)
STPKG_ANIMATED_TARGET_FILETYPE="$2"
shift 2
;;
# Generate preview of the sticker pack
-preview)
STPKG_GENERATE_PREVIEW="yes"
shift
;;
*)
local PARSE_FLAGS=0
;;
esac
done
# Default values
STPKG_MAX_WIDTH=${STPKG_MAX_WIDTH:="256"}
STPKG_MAX_HEIGHT=${STPKG_MAX_HEIGHT:="128"}
STPKG_TRUST_SOURCE=${STPKG_TRUST_SOURCE:="no"}
STPKG_GENERATE_PREVIEW=${STPKG_GENERATE_PREVIEW:="no"}
STPKG_IMAGE_TARGET_FILETYPE=${STPKG_IMAGE_TARGET_FILETYPE:="png"}
STPKG_ANIMATED_TARGET_FILETYPE=${STPKG_ANIMATED_TARGET_FILETYPE:="gif"}
;;&
*)
......
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