mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 15:45:06 +00:00
feature: mo update --force flag implementation (#360)
This commit is contained in:
25
mole
25
mole
@@ -231,6 +231,7 @@ show_help() {
|
|||||||
|
|
||||||
# Update flow (Homebrew or installer).
|
# Update flow (Homebrew or installer).
|
||||||
update_mole() {
|
update_mole() {
|
||||||
|
local force_update="${1:-false}"
|
||||||
local update_interrupted=false
|
local update_interrupted=false
|
||||||
trap 'update_interrupted=true; echo ""; exit 130' INT TERM
|
trap 'update_interrupted=true; echo ""; exit 130' INT TERM
|
||||||
|
|
||||||
@@ -250,7 +251,7 @@ update_mole() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$VERSION" == "$latest" ]]; then
|
if [[ "$VERSION" == "$latest" && "$force_update" != "true" ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${GREEN}${ICON_SUCCESS}${NC} Already on latest version (${VERSION})"
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Already on latest version (${VERSION})"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -366,6 +367,18 @@ update_mole() {
|
|||||||
if [[ ! -f "$config_dir/lib/core/common.sh" ]]; then
|
if [[ ! -f "$config_dir/lib/core/common.sh" ]]; then
|
||||||
config_dir="$HOME/.config/mole"
|
config_dir="$HOME/.config/mole"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$force_update" == "true" ]]; then
|
||||||
|
if install_output=$(MOLE_VERSION="$update_tag" "$tmp_installer" --prefix "$install_dir" --config "$config_dir" 2>&1); then
|
||||||
|
process_install_output "$install_output" "$latest"
|
||||||
|
else
|
||||||
|
if [[ -t 1 ]]; then stop_inline_spinner; fi
|
||||||
|
rm -f "$tmp_installer"
|
||||||
|
log_error "Update failed"
|
||||||
|
echo "$install_output" | tail -10 >&2 # Show last 10 lines of error
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
if install_output=$(MOLE_VERSION="$update_tag" "$tmp_installer" --prefix "$install_dir" --config "$config_dir" --update 2>&1); then
|
if install_output=$(MOLE_VERSION="$update_tag" "$tmp_installer" --prefix "$install_dir" --config "$config_dir" --update 2>&1); then
|
||||||
process_install_output "$install_output" "$latest"
|
process_install_output "$install_output" "$latest"
|
||||||
else
|
else
|
||||||
@@ -379,6 +392,7 @@ update_mole() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f "$tmp_installer"
|
rm -f "$tmp_installer"
|
||||||
rm -f "$HOME/.cache/mole/update_message"
|
rm -f "$HOME/.cache/mole/update_message"
|
||||||
@@ -766,7 +780,14 @@ main() {
|
|||||||
exec "$SCRIPT_DIR/bin/completion.sh" "${args[@]:1}"
|
exec "$SCRIPT_DIR/bin/completion.sh" "${args[@]:1}"
|
||||||
;;
|
;;
|
||||||
"update")
|
"update")
|
||||||
update_mole
|
local force_update=false
|
||||||
|
for arg in "${args[@]:1}"; do
|
||||||
|
case "$arg" in
|
||||||
|
--force | -f) force_update=true ;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
update_mole "$force_update"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"remove")
|
"remove")
|
||||||
|
|||||||
Reference in New Issue
Block a user