Class: BunBun::CLI::StorageFiles

Inherits:
StorageCommand show all
Defined in:
lib/bunbun/cli/storage_files.rb

Instance Attribute Summary

Attributes inherited from StorageCommand

#storage_access_key, #storage_host, #storage_zone

Attributes inherited from Command

#options

Instance Method Summary collapse

Methods inherited from Command

argument_count, argument_names, option, #option_parser, options

Instance Method Details

#call(path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bunbun/cli/storage_files.rb', line 6

def call(path)
  unless path.end_with?('/')
    raise BunBun::CLI::Error, 'path must end with a trailing slash'
  end

  super

  items = client.get(path)

  print_table(items) do |t|
    t.add_column('Name', align_header: :left) { _1['ObjectName'] }
    t.add_column('Size') { format_bytesize(_1['Length']) unless _1['Length'].zero? }
    t.add_column('Created', align_header: :right) { format_timestamp(_1['DateCreated']) }
    t.add_column('Modified', align_header: :right) { format_timestamp(_1['LastChanged']) }
  end
end