Last active
August 12, 2016 22:20
-
-
Save hasufell/0a5eba07a7959d216c1c09e06de2fd20 to your computer and use it in GitHub Desktop.
[PATCH] modules/config: add accept-force and accept-all-force
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 8aa873b74352ce427f02b209696d719ed4e2f7e4 Mon Sep 17 00:00:00 2001 | |
From: Julian Ospald <hasufell@posteo.de> | |
Date: Sat, 13 Aug 2016 00:18:15 +0200 | |
Subject: [PATCH] modules/config: add accept-force and accept-all-force | |
This is useful if we don't want interactive mv mode, e.g. when | |
building docker containers. | |
--- | |
modules/config.eclectic | 45 +++++++++++++++++++++++++++++++++++++++++++-- | |
1 file changed, 43 insertions(+), 2 deletions(-) | |
diff --git a/modules/config.eclectic b/modules/config.eclectic | |
index df79ddb..515c63a 100644 | |
--- a/modules/config.eclectic | |
+++ b/modules/config.eclectic | |
@@ -32,6 +32,9 @@ more files. | |
The 'accept-all' action accepts all proposed changes to all configuration files. | |
Similarly, 'reject-all' rejects all changes. Use with caution. | |
+ | |
+'accept-force' and 'accept-all-force' work like their counterparts without | |
+the '-force' suffix, except that files are overwritten without asking. | |
ENDOFTEXT | |
} | |
@@ -198,7 +201,7 @@ describe_accept() { | |
} | |
do_accept() { | |
- generic_handle_one_file "accept" "accept_handler" "$@" | |
+ MV_CMD="mv -i" generic_handle_one_file "accept" "accept_handler" "$@" | |
} | |
accept_handler() { | |
@@ -219,7 +222,7 @@ accept_handler() { | |
esac | |
fi | |
fi | |
- mv -i "${sfile}" "${dfile}" | |
+ ${MV_CMD:-mv -i} "${sfile}" "${dfile}" | |
done | |
} | |
@@ -227,6 +230,20 @@ options_accept() { | |
find_targets | |
} | |
+### accept-force action ### | |
+ | |
+describe_accept-force() { | |
+ echo "Accept changes to the specified files and overwrite them" | |
+} | |
+ | |
+do_accept-force() { | |
+ MV_CMD="mv -f" generic_handle_one_file "accept" "accept_handler" "$@" | |
+} | |
+ | |
+options_accept-force() { | |
+ find_targets | |
+} | |
+ | |
### reject-all action ### | |
describe_reject-all() { | |
@@ -255,6 +272,20 @@ options_accept-all() { | |
: | |
} | |
+### accept-all-force action ### | |
+ | |
+describe_accept-all-force() { | |
+ echo "Accept all updates and force file overwrite ($(highlight_warning dangerous))" | |
+} | |
+ | |
+do_accept-all-force() { | |
+ generic_handle_all "Accepting" "accept-force" | |
+} | |
+ | |
+options_accept-all-force() { | |
+ : | |
+} | |
+ | |
### merge action ### | |
describe_merge() { | |
@@ -453,6 +484,10 @@ do_interactive() { | |
do_action config accept-all | |
show_list=yes | |
;; | |
+ accept-all-force) | |
+ do_action config accept-all-force | |
+ show_list=yes | |
+ ;; | |
reject-all) | |
do_action config reject-all | |
show_list=yes | |
@@ -489,6 +524,7 @@ do_interactive() { | |
write_list_start "Enter subcommand:" | |
write_kv_list_entry "$(highlight d)isplay" "Display proposed change" | |
write_kv_list_entry "$(highlight a)ccept" "Accept proposed change" | |
+ write_kv_list_entry "accept-force" "Accept proposed change and force file overwrite" | |
write_kv_list_entry "$(highlight r)eject" "Reject proposed change" | |
write_kv_list_entry "$(highlight m)erge" "Merge proposed change" | |
write_kv_list_entry "$(highlight q)uit" "Return to parent menu" | |
@@ -507,6 +543,11 @@ do_interactive() { | |
show_list=yes | |
break | |
;; | |
+ accept-force) | |
+ do_action config accept-force ${command} | |
+ show_list=yes | |
+ break | |
+ ;; | |
r|re|rej|reje|rejec|reject) | |
do_action config reject ${command} | |
show_list=yes | |
-- | |
2.9.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment