commit fa6ce11481d5f14aa43aed92ef90682bf92e5a94
parent 36b805d0ac4246562c00c38ae1c21ab65e774e17
Author: Gaute Hope <eg@gaute.vetsj.com>
Date: Fri, 7 Aug 2015 16:00:35 +0200
xdg: ask user if manual intervention is necessary
Diffstat:
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -7,6 +7,7 @@ require 'ncursesw'
require 'sup/util/ncurses'
require 'sup/util/locale_fiddler'
+require 'sup/util/axe'
no_gpgme = false
begin
@@ -37,11 +38,12 @@ def xdg_data_dir
end
if Dir.exist?((old_sup_dir = File.join(ENV["HOME"], ".sup"))) && !ENV['SUP_BASE']
+
FileUtils.mkdir_p xdg_config_dir
FileUtils.mkdir_p xdg_data_dir
FileUtils.cd old_sup_dir do
- config_files = Dir.entries(old_sup_dir).select do |file|
+ config_files = Dir.entries(old_sup_dir).select do |file|
file =~ /(config|sources|colors)\.?\w*\.yaml(.bak)?/i
end
@@ -50,7 +52,13 @@ if Dir.exist?((old_sup_dir = File.join(ENV["HOME"], ".sup"))) && !ENV['SUP_BASE'
FileUtils.mv Dir.glob("*"), xdg_data_dir
end
FileUtils.remove_dir old_sup_dir
+
+ if axe_yes("sup has moved configuration files, xapian index and all contents of ~/.sup to the default XDG directories, do you need to make any manual changes?", "y")
+ exit
+ end
+
end
+
require 'sup'
if ENV['SUP_PROFILE']
diff --git a/bin/sup-config b/bin/sup-config
@@ -5,6 +5,7 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'highline/import'
require 'trollop'
require "sup"
+require 'sup/util/axe'
$opts = Trollop::options do
version "sup-config (sup #{Redwood::VERSION})"
@@ -19,20 +20,6 @@ No options.
EOS
end
-def axe q, default=nil
- question = if default && !default.empty?
- "#{q} (enter for \"#{default}\"): "
- else
- "#{q}: "
- end
- ans = ask question
- ans.empty? ? default : ans.to_s
-end
-
-def axe_yes q, default="n"
- axe(q, default) =~ /^y|yes$/i
-end
-
def build_cmd cmd
(ENV["RUBY_INVOCATION"] ? ENV["RUBY_INVOCATION"] + " " : "") + File.join(File.dirname($0), cmd)
end
diff --git a/lib/sup/util/axe.rb b/lib/sup/util/axe.rb
@@ -0,0 +1,16 @@
+require 'highline/import'
+
+def axe q, default=nil
+ question = if default && !default.empty?
+ "#{q} (enter for \"#{default}\"): "
+ else
+ "#{q}: "
+ end
+ ans = ask question
+ ans.empty? ? default : ans.to_s
+end
+
+def axe_yes q, default="n"
+ axe(q, default) =~ /^y|yes$/i
+end
+