Class: ImagesConvert::Cleanup

Inherits:
Object
  • Object
show all
Defined in:
lib/images_convert/cleanup.rb

Constant Summary collapse

CONFIG_DIR =
File.expand_path('~/.images-convert')

Class Method Summary collapse

Class Method Details

.run ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/images_convert/cleanup.rb', line 9

def self.run
  if Dir.exist?(CONFIG_DIR)
    puts "設定ファイルとディレクトリを削除しますか? [Y/n]"
    print "> "
    answer = (STDIN.gets || "").strip
    answer = 'y' if answer.empty?

    if answer.downcase.start_with?('y')
      begin
        FileUtils.rm_rf(CONFIG_DIR)
        puts "設定ファイルとディレクトリを削除しました: #{CONFIG_DIR}"
      rescue => e
        puts "削除中にエラーが発生しました: #{e.message}"
      end
    else
      puts "削除をキャンセルしました。設定ファイルは残ります。"
    end
  else
    puts "設定ディレクトリが見つかりません: #{CONFIG_DIR}"
  end
end