From e27ca3019bd4ab324acbc96330fbb0b7173f3fc1 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Tue, 24 Jan 2017 12:00:57 +0530 Subject: [PATCH] FEATURE: posts:remap task now supports removing all occurences of a word --- lib/tasks/posts.rake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake index 7c9c3407c24..53e2706adc4 100644 --- a/lib/tasks/posts.rake +++ b/lib/tasks/posts.rake @@ -118,11 +118,16 @@ end desc 'Remap all posts matching specific string' task 'posts:remap', [:find, :replace] => [:environment] do |_,args| + require 'highline/import' + find = args[:find] replace = args[:replace] - if !find || !replace + if !find puts "ERROR: Expecting rake posts:remap[find,replace]" exit 1 + elsif !replace + confirm_replace = ask("Are you sure you want to remove all occurences of '#{find}'? (Y/n) ") + exit 1 unless (confirm_replace == "" || confirm_replace.downcase == 'y') end puts "Remapping"