Class: CloudappExport::CLI
- Inherits:
-
Thor
- Object
- Thor
- CloudappExport::CLI
- Defined in:
- lib/cloudapp_export/cli.rb
Instance Method Summary collapse
Instance Method Details
#all ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cloudapp_export/cli.rb', line 14 def all authenticate! items = CloudappExport::ItemList.new( api, 'limit' => ['limit'], 'use_cache' => ['cache'], 'cache_key' => "#{username}:#{['limit']}", ) say("Account contains #{set_color items.total_count, :bold} items") say("", nil, true) exporter = ::CloudappExport::Exporter.new( items, 'dir' => ['dir'], ) exporter.on_log do || print end exporter.export_all end |
#stats ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cloudapp_export/cli.rb', line 40 def stats authenticate! items = CloudappExport::ItemList.new( api, ) say("Account contains #{set_color items.total_count, :bold} items") say("", nil, true) say("Dir #{['dir']}") say("", nil, true) # TODO: Just count files directly in local folder downloaded_items = items.data.select { |item| File.exist?("#{['dir']}/#{item.filename}") } downloaded_items_size = downloaded_items.inject(0) { |sum, item| sum + File.size("#{['dir']}/#{item.filename}") } say("Downloaded #{downloaded_items.count}") say(" #{(downloaded_items_size.to_f / 1_000_000).round 2} mb") end |