Allow multiple strategies on editor resolution

This commit is contained in:
Juno Takano 2024-07-20 16:32:36 -03:00
parent 00d1fa3ff0
commit 7868149bbf
3 changed files with 20 additions and 18 deletions

View file

@ -17,7 +17,8 @@ package_conflict_input_parser() {
$EDITOR "$input" $EDITOR "$input"
choices="$(cat "$input" | grep -v '^#' | grep '.')" > "$input_choices" choices="$(cat "$input" | grep -v '^#' | grep '.')"
echo "$choices" > "$input_choices"
# validation # validation
while read -r action package; do while read -r action package; do
@ -35,25 +36,27 @@ package_conflict_input_parser() {
elif [ "$action" = skip ] || [ "$action" = s ]; then elif [ "$action" = skip ] || [ "$action" = s ]; then
log debug "[package_conflict_input_parser] Skipped: $package" log debug "[package_conflict_input_parser] Skipped: $package"
else else
log user "Invalid action provided: $action" log user "Invalid action provided for $package: $action"
fi fi
done < "$input_choices" done < "$input_choices"
# actual system or configuration change # actual system or configuration change
echo "$choices" | while read -r action package; do if [ -n "$packages_to_install" ]; then
if [ "$action" = install ] || [ "$action" = i ]; then package_manager install "$packages_to_install"
package_manager install "$packages_to_install" fi
elif [ "$action" = uninstall ] || [ "$action" = u ]; then
debug info "Calling package manager to uninstall $packages_to_uninstall"
package_manager uninstall "$packages_to_uninstall"
elif [ "$action" = add ] || [ "$action" = a ]; then
track_packages "$package"
elif [ "$action" = remove ] || [ "$action" = r ]; then
untrack_packages "$package"
fi
done
}
if [ -n "$packages_to_uninstall" ]; then
package_manager uninstall "$packages_to_uninstall"
fi
if [ -n "$packages_to_track" ]; then
track_packages "$packages_to_track"
fi
if [ -n "$packages_to_untrack" ]; then
untrack_packages "$packages_to_untrack"
fi
}
help_text_generator() { help_text_generator() {
local conflict_type="$1" local conflict_type="$1"

View file

@ -9,10 +9,10 @@ track_packages() {
untrack_packages() { untrack_packages() {
local packages="$1" local packages="$1"
log debug "[untrack_packages] Removing packages: $packages" log info "[untrack_packages] Removing packages: $packages"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
sed -i '' "/^[[:space:]]*$package[[:space:]]*$/d" "$CONFIG_ROOT/packages" sed -i '' "/^[[:space:]]*$package[[:space:]]*$/d" "$CONFIG_ROOT/packages"
log debug "[untrack_packages] Executed removal for $package with exit code $?" log info "[untrack_packages] Executed removal for $package with exit code $?"
done done
} }

1
tori
View file

@ -69,7 +69,6 @@ check_core_paths() {
exit 1 exit 1
fi fi
[ -n "$DEBUG" ] && echo "TORI_ROOT: $TORI_ROOT"
} }
main "$1" "$2" main "$1" "$2"