forked from Shinonome/dots-hyprland
feat(exp-update): support string inputs in interactive mode and help text
This commit is contained in:
@@ -371,23 +371,23 @@ handle_file_conflict() {
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if ! safe_read "Enter your choice (1-8) [${default_val}]: " choice "$default_val"; then
|
if ! safe_read "Enter your choice (1-8 or name) [${default_val}]: " choice "$default_val"; then
|
||||||
echo
|
echo
|
||||||
log_warning "Failed to read input. Skipping file."
|
log_warning "Failed to read input. Skipping file."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate choice
|
# Validate choice
|
||||||
if [[ "$choice" =~ ^[1-8]$ ]]; then
|
if [[ "$choice" =~ ^[1-8]$ ]] || [[ "$choice" =~ ^(replace|keep|old|new|diff|skip|ignore|backup)$ ]]; then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo "Invalid choice. Please enter 1-8."
|
echo "Invalid choice. Please enter 1-8 or a valid name (replace, keep, old ...)."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $choice in
|
case $choice in
|
||||||
1)
|
1|replace)
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
log_info "[DRY-RUN] Would replace $home_file with repository version"
|
log_info "[DRY-RUN] Would replace $home_file with repository version"
|
||||||
else
|
else
|
||||||
@@ -395,10 +395,10 @@ handle_file_conflict() {
|
|||||||
log_success "Replaced $home_file with repository version"
|
log_success "Replaced $home_file with repository version"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
2)
|
2|keep)
|
||||||
log_info "Keeping local version of $home_file"
|
log_info "Keeping local version of $home_file"
|
||||||
;;
|
;;
|
||||||
3)
|
3|old)
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
log_info "[DRY-RUN] Would backup local file to ${filename}.old and update with repository version"
|
log_info "[DRY-RUN] Would backup local file to ${filename}.old and update with repository version"
|
||||||
else
|
else
|
||||||
@@ -407,7 +407,7 @@ handle_file_conflict() {
|
|||||||
log_success "Backed up local file to ${filename}.old and updated with repository version"
|
log_success "Backed up local file to ${filename}.old and updated with repository version"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
4)
|
4|new)
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
log_info "[DRY-RUN] Would save repository version as ${filename}.new, keep local file"
|
log_info "[DRY-RUN] Would save repository version as ${filename}.new, keep local file"
|
||||||
else
|
else
|
||||||
@@ -415,7 +415,7 @@ handle_file_conflict() {
|
|||||||
log_success "Saved repository version as ${filename}.new, kept local file"
|
log_success "Saved repository version as ${filename}.new, kept local file"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
5)
|
5|diff)
|
||||||
show_diff "$home_file" "$repo_file"
|
show_diff "$home_file" "$repo_file"
|
||||||
echo
|
echo
|
||||||
echo "After reviewing the diff, choose:"
|
echo "After reviewing the diff, choose:"
|
||||||
@@ -487,10 +487,10 @@ handle_file_conflict() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
6)
|
6|skip)
|
||||||
log_info "Skipping $home_file"
|
log_info "Skipping $home_file"
|
||||||
;;
|
;;
|
||||||
7)
|
7|ignore)
|
||||||
local relative_path_to_home="${home_file#$HOME/}"
|
local relative_path_to_home="${home_file#$HOME/}"
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
log_info "[DRY-RUN] Would add '$relative_path_to_home' to $XDG_UPDATE_IGNORE_FILE"
|
log_info "[DRY-RUN] Would add '$relative_path_to_home' to $XDG_UPDATE_IGNORE_FILE"
|
||||||
@@ -499,7 +499,7 @@ handle_file_conflict() {
|
|||||||
log_success "Added '$relative_path_to_home' to $XDG_UPDATE_IGNORE_FILE and skipped."
|
log_success "Added '$relative_path_to_home' to $XDG_UPDATE_IGNORE_FILE and skipped."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
8)
|
8|backup)
|
||||||
if backup_file "$home_file"; then
|
if backup_file "$home_file"; then
|
||||||
if [[ "$DRY_RUN" != true ]]; then
|
if [[ "$DRY_RUN" != true ]]; then
|
||||||
cp -p "$repo_file" "$home_file"
|
cp -p "$repo_file" "$home_file"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Options:
|
|||||||
-h, --help Show this help message
|
-h, --help Show this help message
|
||||||
-s, --skip-notice Skip notice about script being untested
|
-s, --skip-notice Skip notice about script being untested
|
||||||
--non-interactive
|
--non-interactive
|
||||||
Set default choice for file conflicts (usually used with --non-interactive)
|
Set default choice for file conflicts
|
||||||
replace: Replace local keep: Keep local old: Backup as .old
|
replace: Replace local keep: Keep local old: Backup as .old
|
||||||
new: Save as .new diff: Show diff skip: Skip
|
new: Save as .new diff: Show diff skip: Skip
|
||||||
ignore: Add to ignore backup: Backup and replace
|
ignore: Add to ignore backup: Backup and replace
|
||||||
|
|||||||
Reference in New Issue
Block a user