Switch charmcraft aliases:
Usage examples:
charmcraft-workon 1.5
charmcraft-workon 2.0
#!/bin/bash -e | |
VERSION=${1:-""} | |
if [ "x${VERSION}" == "x" ]; then | |
echo -e "\nCurrent: $(file /snap/bin/charmcraft)" | |
echo -e "\nUsage example:" | |
echo " charmcraft-workon 1.5" | |
exit 1 | |
fi | |
SNAP_SUFIX=$(echo $VERSION | sed 's/\./pt/') | |
TARGET=charmcraft_${SNAP_SUFIX} | |
if [ -f /snap/bin/${TARGET} ]; then | |
sudo snap unalias charmcraft | |
sudo snap alias ${TARGET} charmcraft | |
else | |
echo "The requested version doesn't exist, please install it running:" | |
echo " sudo snap install --classic charmcraft_${SNAP_SUFIX}" | |
exit 2 | |
fi |