Method: Command::Backup#execute

Defined in:
lib/command/backup.rb

#execute(argv) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/command/backup.rb', line 61

def execute(argv)
  super
  if argv.empty?
    puts @opt.help
    return
  end
  tagname_to_ids(argv)
  require "zip"
  argv.each_with_index do |target, i|
    Helper.print_horizontal_rule if i > 0
    data = Downloader.get_data_by_target(target)
    unless data
      puts "#{target} は存在しません"
      next
    end
    puts "ID:#{data["id"]} #{data["title"]}"
    print "バックアップを作成しています"
    Thread.new {
      loop do
        print "."
        sleep(0.5)
      end
    }.tap { |th|
      zipfilename =  create_backup(data)
      th.kill
      puts
      puts "#{zipfilename} を作成しました"
    }
  end
end